Does using Provider mean no Stateful Widgets?

Issue

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!

Solution

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.

Answered By – Sanketh B. K

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *