Wrap app in zone guard

This commit is contained in:
OmarHatem 2022-11-23 18:06:09 +02:00
parent 9b32c9c956
commit 38da6e73d4

View file

@ -42,9 +42,16 @@ final navigatorKey = GlobalKey<NavigatorState>();
final rootKey = GlobalKey<RootState>();
Future<void> main() async {
try {
await runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
// FlutterError.onError = ;
// Isolate.current.addErrorListener(RawReceivePort((pair) async {
// final List<dynamic> errorAndStacktrace = pair;
// }).sendPort);
final appDir = await getApplicationDocumentsDirectory();
await Hive.close();
Hive.init(appDir.path);
@ -130,7 +137,7 @@ Future<void> main() async {
secureStorage: secureStorage,
initialMigrationVersion: 17);
runApp(App());
} catch (e, stacktrace) {
}, (error, stackTrace) {
runApp(MaterialApp(
debugShowCheckedModeBanner: true,
home: Scaffold(
@ -138,10 +145,10 @@ Future<void> 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<void> initialSetup(