onError method Null safety

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

Called whenever an error occurs and notifies BlocObserver.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
void onError(Object error, StackTrace stackTrace) {
  // ignore: invalid_use_of_protected_member
  _blocObserver?.onError(this, error, stackTrace);
}