redux_persist_flutter 0.4.2 redux_persist_flutter: ^0.4.2 copied to clipboard
Redux Persist Flutter Integration
redux_persist_flutter #
Flutter Storage Engine for redux_persist
.
Can either save to shared_preferences
(default, recommended), or your
application document directory.
Defaults to saving to
shared_preferences
(recommended).
To save to a file in your
application document directory,
simply change the location
:
Usage #
var persistor = new Persistor<AppState>(
// ...
storage: new FlutterStorage("my-app"),
);
Locations #
By default, it saves to FlutterSaveLocation.sharedPreference
(shared_preferences
, recommended).
You can also save to your application document directory
by using FlutterSaveLocation.documentFile
:
new FlutterStorage("my-app", location: FlutterSaveLocation.documentFile)
PersistorGate
#
If you want to wait until rendering you app until the state is loaded,
use the PersistorGate
:
@override
Widget build(BuildContext context) {
return new 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
:
new PersistorGate(
persistor: persistor,
loading: SlashScreen(), // !!!
builder: (context) => MyApp(),
);
Features and bugs #
Please file feature requests and bugs at the issue tracker.