runApp function

void runApp(
  1. Widget app, {
  2. FlutterExceptionHandler? onError,
  3. bool? runZoneGuard,
})

Add an Error Handler right at the start.

Implementation

void runApp(
  m.Widget app, {
  FlutterExceptionHandler? onError,
  bool? runZoneGuard,
}) {
  // Ignore runZoneGuard gp
  // Instantiate the app's error handler.
  final handler = c.AppErrorHandler();

  // Assign an error handler (Will be replaced after)
  c.AppErrorHandler.set(handler: _RunWebAppErrorHandler(onError).handler);

  // Here we set the URL strategy for our web app.
  // It is safe to call this function when running on mobile or desktop as well.
  if (urlStrategy is! PathUrlStrategy) {
    usePathUrlStrategy();
  }

  // Run in a new zone with an error handler
  if (runZoneGuard ?? false) {
    // Catch any errors attempting to execute runApp();
    runZonedGuarded(() {
      m.runApp(app);
    }, handler.runZonedError);
  } else {
    // Since Flutter 3.10, must now run in the 'root' zone
    m.runApp(app);
  }
}