List of state management approaches
- General overview
- Provider
- Riverpod
- setState
- ValueNotifier & InheritedNotifier
- InheritedWidget & InheritedModel
- June
- Redux
- Fish-Redux
- BLoC / Rx
- GetIt
- MobX
- Dart Board
- Flutter Commands
- Binder
- GetX
- states_rebuilder
- Triple Pattern (Segmented State Pattern)
- solidart
- flutter_reactive_value
- Elementary
State management is a complex topic. If you feel that some of your questions haven't been answered, or that the approach described on these pages is not viable for your use cases, you are probably right.
Learn more at the following links, many of which have been contributed by the Flutter community:
General overview
#Things to review before selecting an approach.
- Introduction to state management, which is the beginning of this very section (for those of you who arrived directly to this Options page and missed the previous pages)
- Pragmatic State Management in Flutter, a video from Google I/O 2019
- Flutter Architecture Samples, by Brian Egan
Provider
#- Simple app state management, the previous page in this section
- Provider package
Riverpod
#Riverpod works in a similar fashion to Provider. It offers compile safety and testing without depending on the Flutter SDK.
setState
#The low-level approach to use for widget-specific, ephemeral state.
- Adding interactivity to your Flutter app, a Flutter tutorial
- Basic state management in Google Flutter, by Agung Surya
ValueNotifier & InheritedNotifier
#An approach using only Flutter provided tooling to update state and notify the UI of changes.
- State Management using ValueNotifier and InheritedNotifier, by Tadas Petra
InheritedWidget & InheritedModel
#The low-level approach used to communicate between ancestors and children in the widget tree. This is what provider
and many other approaches use under the hood.
The following instructor-led video workshop covers how to use InheritedWidget
:
How to manage application state using inherited widgets
Other useful docs include:
- InheritedWidget docs
- Managing Flutter Application State With InheritedWidgets, by Hans Muller
- Inheriting Widgets, by Mehmet Fidanboylu
- Using Flutter Inherited Widgets Effectively, by Eric Windmill
- Widget - State - Context - InheritedWidget, by Didier Bolelens
June
#A lightweight and modern state management library that focuses on providing a pattern similar to Flutter's built-in state management.
Redux
#A state container approach familiar to many web developers.
- Animation Management with Redux and Flutter, a video from DartConf 2018 Accompanying article on Medium
- Flutter Redux package
- Redux Saga Middleware Dart and Flutter, by Bilal Uslu
- Introduction to Redux in Flutter, by Xavi Rigau
- Flutter + Redux—How to make a shopping list app, by Paulina Szklarska on Hackernoon
- Building a TODO application (CRUD) in Flutter with Redux—Part 1, a video by Tensor Programming
- Flutter Redux Thunk, an example, by Jack Wong
- Building a (large) Flutter app with Redux, by Hillel Coren
- Fish-Redux–An assembled flutter application framework based on Redux, by Alibaba
- Async Redux–Redux without boilerplate. Allows for both sync and async reducers, by Marcelo Glasberg
- Flutter meets Redux: The Redux way of managing Flutter applications state, by Amir Ghezelbash
- Redux and epics for better-organized code in Flutter apps, by Nihad Delic
- Flutter_Redux_Gen - VS Code Plugin to generate boiler plate code, by Balamurugan Muthusamy (BalaDhruv)
Fish-Redux
#Fish Redux is an assembled flutter application framework based on Redux state management. It is suitable for building medium and large applications.
- Fish-Redux-Library package, by Alibaba
- Fish-Redux-Source, project code
- Flutter-Movie, A non-trivial example demonstrating how to use Fish Redux, with more than 30 screens, graphql, payment api, and media player.
BLoC / Rx
#A family of stream/observable based patterns.
- Architect your Flutter project using BLoC pattern, by Sagar Suri
- BloC Library, by Felix Angelov
- Reactive Programming - Streams - BLoC - Practical Use Cases, by Didier Boelens
GetIt
#A service locator based state management approach that doesn't need a BuildContext
.
- GetIt package, the service locator. It can also be used together with BloCs.
- GetIt Mixin package, a mixin that completes
GetIt
to a full state management solution. - GetIt Hooks package, same as the mixin in case you already use
flutter_hooks
. - Flutter state management for minimalists, by Suragch
MobX
#A popular library based on observables and reactions.
- MobX.dart, Hassle free state-management for your Dart and Flutter apps
- Getting started with MobX.dart
- Flutter: State Management with Mobx, a video by Paul Halliday
Dart Board
#A modular feature management framework for Flutter. Dart Board is designed to help encapsulate and isolate features, including examples/frameworks, small kernel, and many ready-to-use decoupled features such as debugging, logging, auth, redux, locator, particle system and more.
Flutter Commands
#Reactive state management that uses the Command Pattern and is based on ValueNotifiers
. Best in combination with GetIt, but can be used with Provider
or other locators too.
- Flutter Command package
- RxCommand package,
Stream
based implementation.
Binder
#A state management package that uses InheritedWidget
at its core. Inspired in part by recoil. This package promotes the separation of concerns.
- Binder package
- Binder examples
- Binder snippets, vscode snippets to be even more productive with Binder
GetX
#A simplified reactive state management solution.
- GetX package
- GetX Flutter Firebase Auth Example, by Jeff McMorris
states_rebuilder
#An approach that combines state management with a dependency injection solution and an integrated router. For more information, see the following info:
- States Rebuilder project code
- States Rebuilder documentation
Triple Pattern (Segmented State Pattern)
#Triple is a pattern for state management that uses Streams
or ValueNotifier
. This mechanism (nicknamed triple because the stream always uses three values: Error
, Loading
, and State
), is based on the Segmented State pattern.
For more information, refer to the following resources:
- Triple documentation
- Flutter Triple package
- Triple Pattern: A new pattern for state management in Flutter (blog post written in Portuguese but can be auto-translated)
- VIDEO: Flutter Triple Pattern by Kevlin Ossada (recorded in English)
solidart
#A simple but powerful state management solution inspired by SolidJS.
flutter_reactive_value
#The flutter_reactive_value
library might offer the least complex solution for state management in Flutter. It might help Flutter newcomers add reactivity to their UI, without the complexity of the mechanisms described before. The flutter_reactive_value
library defines the reactiveValue(BuildContext)
extension method on ValueNotifier
. This extension allows a Widget
to fetch the current value of the ValueNotifier
and subscribe the Widget
to changes in the value of the ValueNotifier
. If the value of the ValueNotifier
changes, Widget
rebuilds.
flutter_reactive_value
source and documentation
Elementary
#Elementary is a simple and reliable way to build applications with MVVM in Flutter. It offers a pure Flutter experience with clear code separation by responsibilities, efficient rebuilds, easy testability, and enhancing team productivity.
Unless stated otherwise, the documentation on this site reflects the latest stable version of Flutter. Page last updated on 2024-08-19. View source or report an issue.