AnyNotifier<StateT, ValueT> class
abstract
Notifiers
A base class for all "notifiers".
This is a good interface to target for writing mixins for Notifiers.
To perform logic before/after the build
method of a notifier, you can override
runBuild:
mixin MyMixin<T> extends AnyNotifier<T, FutureOr<T>> {
@override
void runBuild() {
// It is safe to use "ref" here.
listenSelf((prev, next) => print("New state $next"));
print('Before build');
super.runBuild();
print('After build');
}
}
- Available extensions
- Annotations
-
- @publicInRiverpodAndCodegen
Constructors
Properties
Methods
-
listenSelf(
void listener(StateT? previous, StateT next), {void onError(Object error, StackTrace stackTrace)?}) → RemoveListener - Listens to changes on the value exposed by this provider.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
persist<
KeyT, EncodedT> (FutureOr< Storage< storage, {required KeyT key, required EncodedT encode(ValueT state), required ValueT decode(EncodedT encoded), StorageOptions options = const StorageOptions()}) → PersistResultKeyT, EncodedT> > -
Available on AnyNotifier<
Persist the state of a provider to a database.StateT, ValueT> , provided by the NotifierPersistX extension -
runBuild(
) → void - Executes Notifier.build.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateShouldNotify(
StateT previous, StateT next) → bool - A method invoked when the state exposed by this Notifier changes. It compares the previous and new value, and return whether listeners should be notified.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited