Dart Tutorial

Flutter Chapter 7 of 16

State Management

Keep your UI in step with your data: setState, lifting state up, InheritedWidget, ChangeNotifier, Provider, Riverpod and Bloc.

State management is the topic Flutter developers argue about most. The ideas are simpler than the arguments suggest. This chapter builds up from setState to the popular packages, so you understand what each one is doing for you.

Lessons in this chapter

  1. State in Flutter: setState and Lifting State UpUnderstand state in Flutter: ephemeral versus app state, how setState works, lifting state up to share it, and passing callbacks down.
  2. InheritedWidget in FlutterLearn how InheritedWidget shares data down the widget tree in Flutter, how of(context) works, and why Provider is built on it.
  3. ValueNotifier and ChangeNotifier in FlutterManage state in Flutter without packages using ValueNotifier, ChangeNotifier, ValueListenableBuilder and ListenableBuilder.
  4. Provider in Flutter: State Management TutorialLearn the provider package in Flutter: ChangeNotifierProvider, context.watch, read and select, Consumer and MultiProvider, with a cart example.
  5. Riverpod in Flutter: Providers, Notifiers and Async StateLearn Riverpod for Flutter: ProviderScope, ref.watch and ref.read, Notifier, FutureProvider and AsyncValue, with complete examples.
  6. Bloc and Cubit in FlutterLearn the Bloc pattern in Flutter with flutter_bloc: Cubit, Bloc with events, BlocProvider, BlocBuilder, BlocListener and state classes.
  7. Choosing a State Management Approach in FlutterCompare setState, ChangeNotifier, Provider, Riverpod and Bloc for Flutter, and learn how to choose the right one for your project.