runAppBootstrap function

Future<void> runAppBootstrap(
  1. Future<Widget> builder(), {
  2. OnError? onError,
})

Run a Flutter app with a bootstrap that catches errors. By default onError will use BoltLogger to log the error.

Implementation

Future<void> runAppBootstrap(Future<Widget> Function() builder, {OnError? onError}) async {
  final errorLogger =
      onError ??
      (exception, stackTrace) {
        BoltLogger.shock([exception, stackTrace]);
      };

  await runZonedGuarded(() async {
    WidgetsFlutterBinding.ensureInitialized();
    FlutterError.onError = (details) => errorLogger(details.exception, details.stack);

    runApp(await builder());
  }, errorLogger);
}