onError method

  1. @override
void onError(
  1. ErrorType type,
  2. Object error,
  3. StackTrace? stackTrace,
  4. FlutterErrorDetails? flutterErrorDetails,
)
override

The callback which is called when an error occurs.

Implementation

@override
void onError(
  ErrorType type,
  Object error,
  StackTrace? stackTrace,
  FlutterErrorDetails? flutterErrorDetails,
) {
  if (kDebugMode) {
    if (ErrorType.flutter == type && null != flutterErrorDetails) {
      FlutterError.presentError(flutterErrorDetails);

      return;
    }

    debugPrint(
      '=================== CAUGHT ${type.toString().split('.').last.toUpperCase()} ERROR',
    );

    debugPrint(error.toString());

    if (null != stackTrace) {
      debugPrint(stackTrace.toString());
    }
  }
}