onChange method
Called whenever a change
occurs with the given change
.
A change
occurs when a new state
is emitted.
onChange is called before the state
of the StateController
is updated.
onChange is a great spot to add logging/analytics for a specific StateController
.
Note: super.onChange
should always be called first.
@override
void onChange(StateChange change) {
// Always call super.onChange with the current change
super.onChange(change);
// Custom onChange logic goes here
}
See also:
- ObserverController for observing StateController behavior globally.
Implementation
@mustCallSuper
void onChange(StateChange<State> change) {
// ignore: invalid_use_of_protected_member
Controller.observer.onChange(this, change);
}