redux_persist
0.9.0, released 6 years ago by cretezy.com
Persist Redux state across app restarts with custom storage engines and serializers
What it does
It creates a Redux middleware that automatically saves your application state to storage on every action, and allows loading the initial state upon startup. It supports custom storage engines and serializers.
AI-written summary of version 0.9.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are using Redux for state management in Flutter or Dart
- You need to persist your application state across app restarts
Skip it when
- You are not using Redux
- You prefer simpler local key-value storage without a state container
Strengths
- Fully type safe
- Supports multiple storage engines (Flutter, Web, File, and custom)
- Includes state and raw transformations and custom serializers
Weaknesses
- Tied directly to the Redux state management ecosystem
- Requires manual serialization logic for state classes
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Not documented
void main() async {
final persistor = Persistor<AppState>(
storage: FileStorage(File("state.json")),
serializer: JsonSerializer<AppState>(AppState.fromJson),
);
final initialState = await persistor.load();
final store = Store<AppState>(
reducer,
initialState: initialState ?? AppState(),
middleware: [persistor.createMiddleware()],
);
}Alternatives
Packages that do the same job and could replace redux_persist.
- yx_state
A state management library for Dart and Flutter applications.
82Compare - cached_query
Library for caching, background fetching, and managing server state in Dart and Flutter.
90Compare - hydrated_mobx
Automatically persist and restore MobX state stores.
73Compare - refena
A state management and dependency injection library inspired by Riverpod and async_redux.
87Compare
Works with
Packages commonly used together with redux_persist: ones it builds on, ones built on it, and its own family.
- synchronizedredux_persist depends on itLock mechanism to prevent concurrent access to asynchronous code.
- reduxredux_persist depends on itPredictable state container for Dart and Flutter using Redux pattern.
- redux_persist_flutterBuilt on redux_persistFlutter storage engine for redux_persist, saving state to a file or shared preferences.