runBuild method
Executes Notifier.build.
This is called by Riverpod, and should not be called manually.
The purpose of this method is to allow mixins to perform logic
before/after the build method of a notifier.
For example, you could implement a mixin that logs state changes:
mixin LoggingMixin<T> on AnyNotifier<T> {
@override
WhenComplete runBuild() {
print('Will build $this');
final result = super.runBuild();
print('Did build $this');
return result;
}
}
The benefit of this method is that it applies on all notifiers, regardless of whether they use arguments or not.
Implementation
@$mustCallSuper
@override
WhenComplete runBuild() {
final ref = this.ref as $Ref<AsyncValue<void>, AsyncValue<void>>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<AsyncValue<void>, AsyncValue<void>>,
AsyncValue<void>,
Object?,
Object?
>;
return element.handleCreate(ref, build);
}