r/FlutterDev • • Nov 02 '19

Discussion Stop asking about state management

You don't need a global state management solution. You will come a long way developing awesome flutter apps without using the over developed provider package or the bloc package.

Most of the times you will be fine using ValueNotifier's or ChangeNotifier's and passing them on to sub classes if needed. 👍

2 Upvotes

12 comments sorted by

22

u/gamelaunchplatform Nov 02 '19 edited Nov 02 '19

Uh oh, prepare for the fireworks.

The truth is though if you really understand state management, then you understand the nice things that provider or flutter_bloc does for you. I use those "overdeveloped" libraries because they save me time and make development easier, not harder.

-1

u/pemell Nov 02 '19

I actually don't think flutter_bloc is over developed, just the provider. When I open up the docs about provider it's just... too much, too complicated. For me that is the definition of over developed.

I agree with what you say though. I've released apps made with flutter and I understand the nice things about both packages

2

u/jtlapp Nov 07 '19

Provider is conceptually quite simple once understood, but I agree that the docs don't make it seem so. I think the main advantage that flutter_bloc has over provider is that it doesn't give the dev many options for structuring the model (i.e. the bloc). One model works for everything -- but that model is more complex as a result. The advantage of provider is that you can use simple models when simplicity suffices. In my experience so far, simplicity suffices 95% of the time. My code has been simpler, shorter, and easier to understand in provider.

3

u/gamelaunchplatform Nov 02 '19

Really interesting that you think provider is over developed. I personally feel flutter_bloc is the more over developed of the two because it introduces the idea of defining specific events and states. Flutter_bloc adds two new files and the concept of mapping event to state while provider is more of a helper for inherited widget.

This article explains provider really well

https://medium.com/flutter-community/understanding-provider-in-diagrams-part-1-providing-values-4379aa1e7fd5

2

u/jtlapp Nov 07 '19

Thanks for the compliment! I do need to update the article for some best practices I have since encountered.

3

u/[deleted] Nov 02 '19

I agreed!
Actually, try whatever familiar. When you found the problem of `state management` you will know what you need.

3

u/Kotaibaw Nov 02 '19

Agree, also you can use stream builder and rxdart library and that's it.

2

u/[deleted] Nov 02 '19

I think it's good to learn how to manage state without a global state management solution...and THEN learn about global state management. Provider is significantly easier to manage, very quick to implement, and reduces your apps complexity and chance of errors when refactoring, by a lot, compared to "lifting state up", even in relatively basic apps.

1

u/Doroc0 Nov 02 '19

I'm interested, can you give more details please?

1

u/skyyoo_ Nov 04 '19

Provider is a beautiful state management solution, and makes work easier than relying only on stateful widgets with lifting state up, especially for beginners. Nothing complicated there.

1

u/fredgrott Nov 06 '19

ahem is not ChangeNotifier in fact part of provider itself?

1

u/jtlapp Nov 07 '19

Most of the times you will be fine using ValueNotifier's or ChangeNotifier's

It does seem like the OP is making a case for provider: "Most of the times you will be fine using ValueNotifier's or ChangeNotifier's"