Persistor<St> class
abstract
Use it like this:
var persistor = MyPersistor();
var initialState = await persistor.readState();
if (initialState == null) {
initialState = AppState.initialState();
await persistor.saveInitialState(initialState);
}
var store = Store<AppState>(
initialState: initialState,
persistor: persistor,
);
IMPORTANT: When the store is created with a Persistor, the store considers that the provided initial-state was already persisted. You have to make sure this is the case.
- Implementers
Constructors
Properties
Methods
-
deleteState(
) → Future< void> - Delete the saved state from the persistence.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
persistDifference(
{required St? lastPersistedState, required St newState}) → Future< void> - Save the new state to the persistence.
-
readState(
) → Future< St?> - Read the saved state from the persistence. Should return null if the state is not yet persisted. This method should be called only once, when the app starts, before the store is created. The state it returns may become the store's initial-state. If some error occurs while loading the info, we have to deal with it by fixing the problem. In the worse case, if we think the state is corrupted and cannot be fixed, one alternative is deleting all persisted files and returning null.
-
saveInitialState(
St state) → Future< void> - Save an initial-state to the persistence.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited