onError method

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

Called whenever an error is thrown within mapEventToState. By default all errors will be ignored and Bloc functionality will be unaffected. The stackTrace argument may be null if the state stream received an error without a stackTrace. A great spot to handle errors at the individual Bloc level.

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);
}

See also:

Implementation

@protected
@mustCallSuper
@override
void onError(Object error, StackTrace stackTrace) {
  super.onError(error, stackTrace);
}