onError abstract method

  1. @protected
  2. @mustCallSuper
  3. @visibleForOverriding
void onError(
  1. Object error,
  2. StackTrace stackTrace
)

Called whenever an error occurs and notifies IBlocObserver.onError.

In debug mode, onError throws a BlocUnhandledErrorException for improved visibility.

In release mode, onError does not throw and will instead only report the error to IBlocObserver.onError.

Note: super.onError should always be called last.

@override
void onError(Object error, StackTrace stackTrace) {
  // Custom onError logic goes here

  // Always call super.onError with the current error and stackTrace
  super.onError(error, stackTrace);
}

Implementation

@protected
@mustCallSuper
@visibleForOverriding
void onError(Object error, StackTrace stackTrace);