Wrap app in zone guard
OmarHatem committed
Nov 23, 2022 at 18:06 UTC
38da6e73d4d6a1ca5a7c13698c58475f70f22919
1 file changed
+11
-4
lib/main.dart
+11
-4
@@ -42,9 +42,16 @@ final navigatorKey = GlobalKey<NavigatorState>();
42
final rootKey = GlobalKey<RootState>();
43
44
Future<void> main() async {
45
- try {
45
+
46
+ await runZonedGuarded(() async {
47
WidgetsFlutterBinding.ensureInitialized();
48
49
+ // FlutterError.onError = ;
50
+
51
+ // Isolate.current.addErrorListener(RawReceivePort((pair) async {
52
+ // final List<dynamic> errorAndStacktrace = pair;
53
+ // }).sendPort);
54
+
55
final appDir = await getApplicationDocumentsDirectory();
56
await Hive.close();
57
Hive.init(appDir.path);
@@ -130,7 +137,7 @@ Future<void> main() async {
137
secureStorage: secureStorage,
138
initialMigrationVersion: 17);
139
runApp(App());
133
- } catch (e, stacktrace) {
140
+ }, (error, stackTrace) {
141
runApp(MaterialApp(
142
debugShowCheckedModeBanner: true,
143
home: Scaffold(
@@ -138,10 +145,10 @@ Future<void> main() async {
145
margin:
146
EdgeInsets.only(top: 50, left: 20, right: 20, bottom: 20),
147
child: Text(
141
- 'Error:\n${e.toString()}\nStacktrace: $stacktrace',
148
+ 'Error:\n${error.toString()}\nStacktrace: $stackTrace',
149
style: TextStyle(fontSize: 22),
150
)))));
144
- }
151
+ });
152
}
153
154
Future<void> initialSetup(