Skip to content
pubscout

redux_persist

0.9.0, released 6 years ago by cretezy.com

Persist Redux state across app restarts with custom storage engines and serializers

$ flutter pub add redux_persist
Source repository

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.

  • cached_query

    Library for caching, background fetching, and managing server state in Dart and Flutter.

  • hydrated_mobx

    Automatically persist and restore MobX state stores.

  • refena

    A state management and dependency injection library inspired by Riverpod and async_redux.

Works with

Packages commonly used together with redux_persist: ones it builds on, ones built on it, and its own family.