diff --git a/lib/main.dart b/lib/main.dart index 3cd5679b3..193240518 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -42,9 +42,16 @@ final navigatorKey = GlobalKey(); final rootKey = GlobalKey(); Future main() async { - try { + + await runZonedGuarded(() async { WidgetsFlutterBinding.ensureInitialized(); + // FlutterError.onError = ; + + // Isolate.current.addErrorListener(RawReceivePort((pair) async { + // final List errorAndStacktrace = pair; + // }).sendPort); + final appDir = await getApplicationDocumentsDirectory(); await Hive.close(); Hive.init(appDir.path); @@ -130,7 +137,7 @@ Future main() async { secureStorage: secureStorage, initialMigrationVersion: 17); runApp(App()); - } catch (e, stacktrace) { + }, (error, stackTrace) { runApp(MaterialApp( debugShowCheckedModeBanner: true, home: Scaffold( @@ -138,10 +145,10 @@ Future main() async { margin: EdgeInsets.only(top: 50, left: 20, right: 20, bottom: 20), child: Text( - 'Error:\n${e.toString()}\nStacktrace: $stacktrace', + 'Error:\n${error.toString()}\nStacktrace: $stackTrace', style: TextStyle(fontSize: 22), ))))); - } + }); } Future initialSetup(