redux
5.0.0, released 6 years ago by fluttercommunity.dev
Predictable state container for Dart and Flutter using Redux pattern.
Flutter FavoriteWASM-ready
What it does
Provides a Store, reducers, and middleware to manage immutable app state in a unidirectional data flow. Works with any Dart code and can be combined with Flutter via flutter_redux.
AI-written summary of version 5.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a single source of truth with explicit state transitions
- You want time‑travel debugging or easy state persistence
- Your app benefits from middleware for logging, async, or side‑effects
Skip it when
- You prefer a more lightweight solution like Provider
- You need built‑in dependency injection or code‑generated models
Strengths
- Clear, testable architecture
- Supports middleware, dev tools, and time‑travel debugging
- Works on all Flutter platforms
Weaknesses
- More boilerplate than simple state solutions
- Steep learning curve for newcomers
- No built‑in DI or code generation
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 0
Add redux to pubspec, then create Store, reducers, and optionally use flutter_redux for UI binding
import 'package:redux/redux.dart';
enum Actions {increment, decrement}
int counterReducer(int state, action) =>
action == Actions.increment ? state + 1 :
action == Actions.decrement ? state - 1 : state;
void main() {
final store = Store<int>(counterReducer, initialState: 0);
store.dispatch(Actions.increment);
print(store.state); // 1
}Alternatives
Packages that do the same job and could replace redux.
Works with
Packages commonly used together with redux: ones it builds on, ones built on it, and its own family.
- flutter_reduxBuilt on reduxUtility widgets that connect Flutter applications to a Redux store.
- over_reactBuilt on reduxA library for building statically-typed React UI components using Dart.
- redux_dev_toolsBuilt on reduxA Redux store wrapper that records state history for time‑travel debugging.
- redux_epicsBuilt on reduxMiddleware for Redux that handles async side effects using Dart Streams
- redux_thunkBuilt on reduxA Redux middleware that allows dispatching async functions as actions.
- redux_sagaBuilt on reduxRedux saga middleware for Dart and Flutter to manage side effects.
- redux_persistBuilt on reduxPersist Redux state across app restarts with custom storage engines and serializers
- redux_loggingBuilt on reduxRedux.dart middleware that logs or prints the latest action, state, and timestamp.