onTransition method

  1. @mustCallSuper
void onTransition(
  1. Transition<Event, State> transition
)

Called whenever a transition occurs with the given transition. A transition occurs when a new event is added and mapEventToState executed. onTransition is called before a bloc's state has been updated. A great spot to add logging/analytics at the individual bloc level.

Note: super.onTransition should always be called last.

@override
void onTransition(Transition<Event, State> transition) {
  // Custom onTransition logic goes here

  // Always call super.onTransition with the current transition
  super.onTransition(transition);
}

Implementation

@mustCallSuper
void onTransition(Transition<Event, State> transition) {
  BlocSupervisor.delegate.onTransition(this, transition);
}