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
void runBuild() {
print('Will build $this');
super.runBuild();
print('Did build $this');
}
}
The benefit of this method is that it applies on all notifiers, regardless of whether they use arguments or not.
Implementation
@$mustCallSuper
@override
void runBuild() {
final created = build();
final ref = this.ref as $Ref<TreeType<NodeData>, TreeType<NodeData>>;
final element = ref.element as $ClassProviderElement<
AnyNotifier<TreeType<NodeData>, TreeType<NodeData>>,
TreeType<NodeData>,
Object?,
Object?>;
element.handleValue(ref, created);
}