onChange abstract method

  1. @protected
  2. @mustCallSuper
  3. @visibleForOverriding
void onChange(
  1. Change<State> change
)

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 bloc is updated. onChange is a great spot to add logging/analytics for a specific bloc.

Note: super.onChange should always be called first.

@override
void onChange(Change change) {
  // Always call super.onChange with the current change
  super.onChange(change);

  // Custom onChange logic goes here
}

See also:

Implementation

@protected
@mustCallSuper
@visibleForOverriding
void onChange(Change<State> change);