Edit: After one year I released new updated article:
Most popular Flutter state management libraries in 2022
Martin Jablečník ・ Jan 1 '22 ・ 9 min read
During learning of Flutter I see that exists many various tools and libraries for state management in Flutter apps.
For me as a beginner is very difficult choose which one is the right and also in the official documentation is plenty of state managers but which is the best for the learning?
Finally I decided to go through all of them and order it by popularity and it can be useful for anybody for better review between.
So here is my list:
Bloc
With the biggest popularity and probably the most used for a big projects. Maintenance is long (2,5 years) and longer than by others projects.
But unfortunately it can be hard for learning and understanding for newcomers and you need to work with a lot of boilerplate in the code.
Popularity:
pub.dev - 1735 likes
github - 6900 stars
Active development: yes
Github link
Provider
Second the most popular library and also officialy recomended by Flutter team as a good choice to use.
Using is simple and learning is also faster then by Bloc.
Popularity:
pub.dev - 3384 likes
github - 3314 stars
Active development: yes
Github link
GetX
Third the most popular library and also the most growing up in popularity right now.
GetX is very simple (similar as Provider), you cannot generate any code (like by MobX), don't have a lot of unnecessary bolerplate code (like by Bloc), you can learn it very fast and it is good for any newcomers.
Popularity:
pub.dev - 3112 likes
github - 2342 stars
Active development: yes
Github link
GetIt
Library inspired by Splat from the React world.
Library is not so popular like previous and maintenance is also a little lower.
Popularity:
pub.dev - 937 likes
github - 621 stars
Active development: for the last year relatively yes
Github link
Riverpod
Successor of Provider state manager developed by same author with a different motivation.
Also nice and very simple like Provider but I don't know if I can use it or not because of lower maintenance during this year..
Popularity:
pub.dev - 496 likes
github - 1210 stars
Active development: for 2020 year yes but from year 2021 is low
MobX
Really nice and simple for newcomers without a lot of boilerplate. Unfortunately you need use builder, automatic generate the code after some change and wait for it.
Library is inspired by MobX project from JavaScript.
Popularity:
pub.dev - 529 likes
github - 1789 stars
Active development: low
Github link
Redux
Probably choice for everybody who have an experiance with React/Redux. Unfortunately maintenance is not so big.
Popularity:
pub.dev - 213 likes
github - 1406 stars
Github link
Active development: a little
Fish redux
Alternative to Redux from Alibaba company.
Popularity:
pub.dev - 41 likes
github - 6900 stars
Active development: no
Github link
Binder
A lightweight, yet powerful way to bind your application state with your business logic. But it's still new yet.
Popularity:
pub.dev - 28 likes
github - 143 stars
Active development: low
Github link
Flutter Commands
Reactive state management that uses the Command Pattern and is based on ValueNotifiers.
Popularity:
pub.dev - 28 likes
github - 17 stars
Active development: no
Github link
Cube
Simple State Manager with dependency injection and no code generation required. I believe that this project is inspired by GetX because I see there a lot of similar things. Unfortunately project is still in early phase (version 0.10.7) but in the future it can be also very interesting alternative..
Popularity:
pub.dev - 11 likes
github - 6 stars
Active development: yes
Github link
Conclusion
After my research I see that really serious candidate for learning from plenty possible libraries, are only three:
1) Bloc
2) Provider
3) GetX
Because of great support, maintenance of and maturity these packages.
So what is my choice?
Finally my choice is GetX state manager.
Although is here only one year and is younger then Bloc or Provider, GetX give me a great, simple and clean solution for my state management and development is really great without any boilerplates.
Moreover GetX give me more then only state management.
GetX contains all ecosystem packages where is State management, Dependency management, Navigation management and other very useful functions which can make my Flutter development simpler and faster.
More about this you can read in my next article
I hope that this article is useful for you and you can let me know it by give a like or some comments below.. ;)
Edit: After one year I released new updated article:
Top comments (6)
Love how concise your article is! But Remi himself wouldn't recommend Provider anymore. I chatted with him this morning and he is recommending River Pod over Provider. You should expect to see most maintenance attention paid to River Pod in the future. Maybe consider updating your article to reflect that?
Another great solution is States_rebuilder which should be added, it has a very nice syntax and a pure dart that supports immutable state management.
pub.dev/packages/states_rebuilder
Not bad, but you can't rely on this package in the long run. Quite interesting and promising features, for example, filtering of reactive events, were silently removed by the author of the package just six months ago. And I have not found the reasons for such refactoring anywhere in the descriptions. I looked at this package too, tested it and gave it up. Personally, I need more package stability.
From my experience, this package has been totally different with the original version 1 and the syntax might not consistent with flutter Bloc package. Personally, that's no right and wrong to keep something innovative and somebody like me always welcome to try something new.
In relation to the reactive event & filtering as you mentioned, I used to define a
dependsOn
into a inject state that can easily achieve global state to state communication (A hasData will trigger B). On the other, for filtering the rebuild by condition, just defineshouldRebuild
, all syntax looks clear and clean.One of the downside of this package is the community is obviously not as popular as others and it's nice to see it keeps growing.
"GetIt isn't a state management solution!"
from its own repos
do you know any good article on how to implement tests with getX and mocktail?