PersistentStateMixin<State> mixin

a mixin to allows you save a state as a JSON in any local database

Superclass Constraints


disposed bool
Tell us if the notifier was disposed
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
returns true when the current notifier has subscribers
no setterinherited
mounted bool
Tell us if the notifier is mounted
no setterinherited
oldState → State
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ↔ State
Updates the State and notify to listeners and rebuild the widgets
getter/setter pairinherited-setteroverride-getter
storage PersistentStateStorage
the storage sho save and return a cached state
no setter
storageKey String
a unique key to identifier the state into the storage
no setter


addListener(ListenerCallback<State> listener) → void
add a new listener
clearListeners() Future<void>
dispose() FutureOr<void>
fromJson(Map<String, dynamic> json) → State?
convert a JSON to one instance of State
loadSavedState() → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
notifyListeners(State data) → void
notify to listeners and rebuild the widgets
onlyUpdate(State newState) → void
updates the state but does not notify to the listeners
onPersistentStateError(Object? e, StackTrace s) → void
a callback to listen when a cached storage couldn't be parsed or if the state couldn't be saved
onStateChanged(State oldState, State currentState) → void
this method is called when the state has been changed
onStateWillChange(State oldState, State newState) bool
this method is called when the state is going to be updated By default this method returns true, you can use this method to intercept the newState and check if the new state is valid. If this method returns false the new state will be igonored
removeListener(ListenerCallback<State> listener, {bool ignoreAutoDispose = false}) → void
remove a listener from the notifier
setDisposableCallback(void disposableCallback()) → void
toJson(State state) Map<String, dynamic>?
convert one instance of State to a JSON to be saved into the storage
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.