Is using Observer design pattern instead of Provider in flutter a good idea?

Viewed 169

The thing is that I have an app where I need to manage data across widgets, and listen to modifications (like perform an action in widget "X" whenever the value of a variable in widget "Y" changes).

So I was thinking, instead of using a whole package and adding a library to my dependencies (I mean provider) and since dart is an Object-oriented programming language... I can use the observer design pattern (pub-sub). this way I can listen to variables' modifications and perform rebuilds only where needed!

Every interaction is highly appreciated!! THANK U!

1 Answers

the provider package is only there to make things easier. I think building your own, or using, a pub-sub wouldn't be any easier.

Flutter already provides a detailed introduction on state management which you should probably check out first. Start by using the tools provided by the core flutter framework. Then you will find out what benefits provider, riverpod, redux, rx, etc. bring to the table and whether they are beneficial to your use cases.

Related