2

I have been fluttering about a month. Still wrapping my head around it all.

Going forward I want to use Provider for state management. Will this mean I can then avoid using:

  1. setState, and
  2. stateful widgets?

Thanks!

  • I asked the same question a few years back. https://stackoverflow.com/questions/59445371/using-flutter-provider-means-no-statefulwidgets – buttonsrtoys Sep 26 '22 at 12:31
  • @buttonsrtoys I just saw this, Wow, that was *exactly* what I asked. Thx for the link! (But you got the guy who created Provider to answer -- nice!) – Rory Prince Apr 14 '23 at 15:01

1 Answers1

3

No, it does not mean the Provider can replace stateful widget.

While deciding between stateful widget and Provider, think about this.

  1. Is is state related to only this component and required by no other component (eg: text inputs from form,..) then use the stateful widget.
  2. Is is the state required by other components in the widget tree? (eg: user authentication state, database connection, ...)then you can go for Provider.
Sanketh B. K
  • 759
  • 8
  • 22
  • Thank you for the reply and info. :) I need to read up on Stateful widgets, but I am getting what you are saying here. – Rory Prince Jan 23 '22 at 17:55