Using Flutter Provider means no StatefulWidgets?

Adding to Rémi's answer and new to this implementation:

  • use Provider for shared models
  • use widget state to manage the model that is specific to that concern when it's needed
  • imagine a user object after auth, null before, shared through an app, with a form with state specific to editing fields, like a nickname, or whatever, updating local state and possibly propagating out to the rest of the product (when finished updating on the backend?...who knows) and that state is disposed of when that view isn't needed anymore, but the user reference remains via the provider reference. It doesn't make sense to manage all that state change in the provider model--that's where the result goes.

Making a few assumptions here based on my experience with React+Redux as well as passing objects around a native Web Components (similar lifecycle to both of these) as well as LitElement. The patterns seem similar if not the same so-far.


Provider.of<ProviderClass>(context, listen: false);

The Provider is one of state management mechanism which Flutter has, under the hood, Provider keeps track of the changes which are done inside the widget. It doesn't matter to Provider whether it's a Stateless widget or Stateful widget, It's gonna rebuild widget if anything gets change.

listen: false tells the Provider not to rebuild widget even if data gets modified. That means it can only re-build if the parent widget gets modified by setState() or by the ProviderClass class value gets modified.


provider doesn't care whether you write stateless/stateful or anything else (hooks?).

It removes the need to write a StatefulWidget in many situations, but it doesn't claim that you should use StatelessWidget only.

In the end, it's your job to decide if you need a StatefulWidget or not. You may need it when writing animations for example.