errorHandler static method

void errorHandler(
  1. FlutterErrorDetails details
)

Explicitly supply an Error Handler

Implementation

static void errorHandler(FlutterErrorDetails details) {
  // The Fluttery Framework's error handler
  final appHandler = AppErrorHandler();

  try {
    // Record the error
    appHandler.getError(details.exception);
    // Handle the Flutter Error Details
    appHandler.handleException(details);
    // This is a public function. ALWAYS catch an error or exception
  } catch (e, stack) {
    // Throw in DebugMode.
    if (kDebugMode) {
      // Set the original error routine. Allows the handler to throw errors.
      FlutterError.onError = appHandler.oldOnError;
      // Rethrow to be handled by the original routine.
      rethrow;
    } else {
      // Record the error in the handler
      appHandler.reportError(
        e,
        stack: stack,
        message: 'Error in errorHandler()',
        library: 'error_handler.dart',
      );
    }
  }
}