Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Are stateful widgets not supposed to be used when working with providers?

This is more of a conceptual question. Going through the flutter documentation I "In Flutter, it makes sense to keep the state above the widgets that use it". Going through the rest of the doc and example code, it seems that the doc wants us to use inly providers as states and use stateless widgets that consume the providers.

Am I correct in understanding that statefull widgets are to be used against stateless + providers or am I incorrect and we can use them both together to some other effect?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, you can use StatefulWidgets with Provider / any state management. Provider provides global variables that needs to be used multiple times on application, or that needs to be stored globally, so those Widgets do not need to be Stateful. But Widgets that their state doesn’t affect other widgets or any other "stuff" on the application can manage their own state.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading