State management packages
Compare Provider, Riverpod and Bloc through data flow, ownership and testing requirements.
This chapter covers state management packages through specific problems and worked examples. Read the lesson descriptions before choosing a starting point. Complete runnable examples are labelled; project configuration and code fragments explain where they belong.
Your lessons
One clear step at a time- 01Flutter Provider: expose a ChangeNotifier modelUse Provider to manage a model scope, watch values during build and invoke actions from callbacks.2 min
- 02Flutter Riverpod: Notifier state and consumer updatesUse a NotifierProvider with a focused state API, and distinguish ref.watch from ref.read in a consumer.2 min
- 03Flutter Bloc and Cubit: model state transitionsCompare Cubit methods with Bloc events, expose immutable state and keep one-time effects separate from rendering.2 min
- 04Choose Flutter state management by ownership and behaviorCompare local state, Provider, Riverpod and Bloc using scope, asynchronous behavior, testability and team requirements.2 min