onDone method

  1. @protected
  2. @mustCallSuper
void onDone(
  1. BaseEvent event, [
  2. Object? error,
  3. StackTrace? stackTrace
])
inherited

Called whenever an event handler for a specific Bloc has completed. This may include an error and stackTrace if an uncaught exception occurred within the event handler.

onDone is called right after the event handler has completed. A great spot to add logging/analytics at the individual Bloc level.

Note: super.onDone should always be called first.

@override
void onDone(Event event, [Object? error, StackTrace? stackTrace]) {
  // Always call super.onDone with the respective event.
  super.onDone(event, error, stackTrace);

  // Custom onDone logic goes here
}

See also:

  • BlocObserver.onDone for observing event handler completions globally.

Implementation

@protected
@mustCallSuper
void onDone(Event event, [Object? error, StackTrace? stackTrace]) {
  // ignore: invalid_use_of_protected_member
  _blocObserver.onDone(this, event, error, stackTrace);
}