HydratedStateNotifier<State> class
abstract
Specialized StateNotifier
which handles initializing the state
based on the persisted state. This allows state to be persisted
across hot restarts as well as complete app restarts.
- Inheritance
-
- Object
- StateNotifier<
State> - HydratedStateNotifier
- Mixed-in types
-
- HydratedMixin<
State>
- HydratedMixin<
Constructors
- HydratedStateNotifier(State state)
-
Initialize
state
and populates the internal storage.
Properties
- debugState → State
-
A development-only way to access
state
outside ofStateNotifier
.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
If a listener has been added using
addListener
and hasn't been removed yet.no setterinherited - id → String
-
id is used to uniquely identify multiple instances
of the same HydratedStateNotifier type.
In most cases it is not necessary;
however, if you wish to intentionally have multiple instances
of the same HydratedStateNotifier, then you must override id
and return a unique identifier for each HydratedStateNotifier instance
in order to keep the caches independent of each other.
no setterinherited
- mounted → bool
-
Whether
dispose
was called or not.no setterinherited - onError ↔ ErrorListener?
-
A callback for error reporting if one of the listeners added with
addListener
throws.getter/setter pairinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state ↔ State
-
The current "state" of this
StateNotifier
.getter/setter pairinherited - storageToken → String
-
storageToken
is used as registration token for hydrated storage.no setterinherited -
stream
→ Stream<
State> -
A broadcast stream representation of a
StateNotifier
.no setterinherited
Methods
-
addListener(
Listener< State> listener, {bool fireImmediately = true}) → RemoveListener -
Subscribes to this object.
inherited
-
clear(
) → Future< void> -
clear is used to wipe or invalidate the cache of a
HydratedStateNotifier.
Calling clear will delete the cached state of the state notifier
but will not modify the current state of the state notifier.
inherited
-
dispose(
) → void -
Frees all the resources associated to this object.
inherited
-
fromJson(
Map< String, dynamic> json) → State? -
Responsible for converting the
Map<String, dynamic>
representation of the state into a concrete instance of the notifier state.inherited -
hydrate(
) → void -
Populates the internal state storage with the latest state.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
State state) → Map< String, dynamic> ? -
Responsible for converting a concrete instance of the state
into the the
Map<String, dynamic>
representation.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
updateShouldNotify(
State old, State current) → bool -
Whether to notify listeners or not when
state
changesinherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited