redux_persist_flutter 0.6.0 copy "redux_persist_flutter: ^0.6.0" to clipboard
redux_persist_flutter: ^0.6.0 copied to clipboard

outdated

Redux Persist Flutter Integration

redux_persist_flutter pub package #

Flutter Storage Engine for redux_persist.

Can either save to shared_preferences (default, recommended), or your application document directory.

Usage #

final persistor = Persistor<State>(
  // ...
  storage: FlutterStorage("my-app"),
);

PersistorGate #

If you want to wait until rendering you app until the state is loaded, use the PersistorGate:

@override
Widget build(BuildContext context) {
  return PersistorGate(
    persistor: persistor,
    builder: (context) => MyApp(),
  );
}

If you want to display a loading/slash screen while loading, pass a widget to render to the loading param of PersistorGate:

PersistorGate(
  persistor: persistor,
  loading: SlashScreen(), // !!!
  builder: (context) => MyApp(),
);

Locations #

By default, it saves to FlutterSaveLocation.documentFile (application document directory, recommended).

You can also save to your shared preferences by using FlutterSaveLocation.sharedPreferences:

// Use shared preferences
FlutterStorage("my-app", location: FlutterSaveLocation.sharedPreferences)

Features and bugs #

Please file feature requests and bugs at the issue tracker.