onEvent method Null safety

  1. @protected
  2. @mustCallSuper
void onEvent(
  1. Event event

Called whenever an event is added to the Bloc. A great spot to add logging/analytics at the individual Bloc level.

Note: super.onEvent should always be called first.

void onEvent(Event event) {
  // Always call super.onEvent with the current event

  // Custom onEvent logic goes here

See also:


void onEvent(Event event) {
  // ignore: invalid_use_of_protected_member
  observer.onEvent(this, event);