File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'dart:async' ;
2
+
3
+ import 'package:dcc_toolkit/logger/bolt_logger.dart' ;
4
+ import 'package:flutter/widgets.dart' ;
5
+
6
+ /// A function that handles errors.
7
+ typedef OnError = void Function (Object error, StackTrace ? stackTrace);
8
+
9
+ /// Run a Flutter app with a bootstrap that catches errors.
10
+ /// By default [onError] will use BoltLogger to log the error.
11
+ Future <void > runAppBootstrap (Future <Widget > Function () builder, {OnError ? onError}) async {
12
+ final errorLogger = onError ??
13
+ (exception, stackTrace) {
14
+ BoltLogger .shock ([exception, stackTrace]);
15
+ };
16
+
17
+ await runZonedGuarded (
18
+ () async {
19
+ WidgetsFlutterBinding .ensureInitialized ();
20
+ FlutterError .onError = (details) => errorLogger (details.exception, details.stack);
21
+
22
+ runApp (await builder ());
23
+ },
24
+ errorLogger,
25
+ );
26
+ }
You can’t perform that action at this time.
0 commit comments