Package selection guidance compiled from public package information, community data, and project usage.
provider_for_redux enables seamless integration between Provider and Redux using AsyncRedux, a lightweight, boilerplate-free Redux implementation. It allows developers to leverage Provider's simplicity for dependency injection while benefiting from Redux's predictable state management. This package is ideal for apps requiring structured state handling without excessive code. It supports all major platforms and simplifies state updates through asynchronous actions and immutable state patterns.
Use cases
Combining Provider with Redux for scalable state management
Building large-scale Flutter apps with predictable state flow
Simplifying state logic in complex applications
Using AsyncRedux with Provider's reactive widgets
Migrating existing Redux logic to a cleaner pattern
Key features
Integrates Provider with AsyncRedux
Reduces boilerplate compared to traditional Redux
Supports async state updates
Provides type-safe state and action handling
Works across all Flutter platforms
Suitable for
Developers familiar with Redux
Teams needing structured state management
Projects requiring both dependency injection and state control
Apps with complex state logic
Those wanting to avoid Redux boilerplate
Considerations
Requires understanding of both Provider and Redux concepts
May add complexity for small apps
Depends on AsyncRedux which has its own learning curve
Not recommended for simple state needs
Best suited for medium to large projects
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
provider_for_redux
With Provider you can inject your state, but it's
your job to figure out how to update that state, structure the solution etc. In other words,
Provider is a great alternative to InheritedWidget, and lets you do dependency injection, but you
still need to do your own state management.
What people mean by “Provider as state management” is usually using Provider to do scoped model. But
as a matter of fact, this is not the only possible architecture using Provider. You can use it with
Bloc, Mobx, Redux and other.
This package lets you use it with AsyncRedux, the
non-boilerplate version of Redux.
How to use it
Please, read the async_redux documentation first,
if you haven't already.
You should have learned that to use AsyncRedux the traditional way, you provide the Redux store to
your app by wrapping it with a StoreProvider, and then using the so called "connector" widgets,
like the MyHomePageConnector below:
Now, if you want to use AsyncRedux with Provider, simply remove the StoreProvider and
use AsyncReduxProvider instead. Also, you won't need the connector widgets anymore, since you will
use Provider instead.
For example:
@overrideWidgetbuild(BuildContext context) =>
AsyncReduxProvider<AppState>.value( // Instead of StoreProvider.
value: store,
child: MaterialApp(
home: MyHomePage(), // Instead of MyHomePageConnector.
));
The AsyncReduxProvider widget above will expose the store, the state, and the dispatch method to
its descendants:
The Redux store, of type Store. Get it like this: Provider.of<Store<AppState>>(context).
The store's state, of type AppState. Get it like this: Provider.of<AppState>(context).
The dispatch method, of type Dispatch. Get it like this: Provider.of<Dispatch>(context).
Your selector parameter must return a "model"
which you can use to build your widget in the builder parameter. In the above example the model is
a Tuple2 instance, but you can return any immutable object that correctly implements equals and
hashcode. The widget will rebuild whenever the model changes.
But it's easier if you use ReduxSelector, which already gives you the store, the state, and the
dispatch method:
However, ReduxSelector also lets you return a List as the model. In case you do that, it will
rebuild the widget whenever any of the items in the list changes:
Using ReduxSelector with a list is the easiest way of all, since you just need to list all of
the state parts that should trigger a rebuild.
Note: The builder gives you both the state and the model, and you can choose one of them
to build your widget from. While using state is probably easier for you, it's also easier to
accidentally use something you forget to add to the model, and then wonder why the Widget doesn't
rebuild. So you have two options:
Use only the model and have the compiler make sure there's no state you're using from outside
of the model.
Use state directly, and have yourself the responsibility to make you've listed everything you'
re using in the model.
When you use AsyncReduxProvider you will notice that both Provider and
AsyncRedux's StoreConnector
will work simultaneously. You can mix and match both of them, as desired, or slowly migrate between
them.