runApp function

void runApp(
  1. Widget app, {
  2. FlutterExceptionHandler? errorHandler,
  3. ErrorWidgetBuilder? errorScreen,
  4. ReportErrorHandler? errorReport,
  5. bool newErrorHandlers = true,
})

Add an Error Handler right at the start.

Implementation

// The 'error' parameters are deprecated.
void runApp(
  m.Widget app, {
  FlutterExceptionHandler? errorHandler,
  m.ErrorWidgetBuilder? errorScreen,
  v.ReportErrorHandler? errorReport,
  bool newErrorHandlers = true,
}) {
  // Instantiate the app's error handler.
  final handler = v.AppErrorHandler(newErrorHandlers: newErrorHandlers);

  Isolate.current.addErrorListener(RawReceivePort((dynamic pair) {
    //
    if (pair is List<dynamic>) {
      final isolateError = pair;
      handler.isolateError(
        isolateError.first.toString(),
        StackTrace.fromString(isolateError.last.toString()),
      );
    }
  }).sendPort);

  // Catch any errors attempting to execute runApp();
  runZonedGuarded(() {
    m.runApp(app);
  }, handler.runZonedError);
}