@@ -11,37 +11,46 @@ import 'package:lunasea/system/cache/memory/memory_store.dart';
11
11
import 'package:lunasea/system/in_app_purchase/in_app_purchase.dart' ;
12
12
import 'package:lunasea/system/localization.dart' ;
13
13
import 'package:lunasea/system/network/network.dart' ;
14
+ import 'package:lunasea/system/recovery_mode/main.dart' ;
14
15
import 'package:lunasea/system/sentry.dart' ;
15
16
import 'package:lunasea/system/window_manager/window_manager.dart' ;
16
17
import 'package:lunasea/system/platform.dart' ;
17
18
18
- /// LunaSea Entry Point: Initialize & Run Application
19
+ /// LunaSea Entry Point: Bootstrap & Run Application
19
20
///
20
21
/// Runs app in guarded zone to attempt to capture fatal (crashing) errors
21
22
Future <void > main () async {
22
23
WidgetsFlutterBinding .ensureInitialized ();
23
24
runZonedGuarded (
24
25
() async {
25
- //LunaSea initialization
26
- await LunaSentry ().initialize ();
27
- await LunaDatabase ().initialize ();
28
- LunaLogger ().initialize ();
29
- if (LunaFirebase .isSupported) await LunaFirebase ().initialize ();
30
- LunaTheme ().initialize ();
31
- if (LunaWindowManager .isSupported) await LunaWindowManager ().initialize ();
32
- if (LunaNetwork .isSupported) LunaNetwork ().initialize ();
33
- if (LunaImageCache .isSupported) LunaImageCache ().initialize ();
34
- LunaRouter ().initialize ();
35
- if (LunaInAppPurchase .isSupported) LunaInAppPurchase ().initialize ();
36
- await LunaLocalization ().initialize ();
37
- await LunaMemoryStore ().initialize ();
38
- // Run application
39
- return runApp (const LunaBIOS ());
26
+ try {
27
+ await bootstrap ();
28
+ runApp (const LunaBIOS ());
29
+ } catch (error) {
30
+ runApp (const LunaRecoveryMode ());
31
+ }
40
32
},
41
33
(error, stack) => LunaLogger ().critical (error, stack),
42
34
);
43
35
}
44
36
37
+ /// Bootstrap the core
38
+ ///
39
+ Future <void > bootstrap () async {
40
+ await LunaSentry ().initialize ();
41
+ await LunaDatabase ().initialize ();
42
+ LunaLogger ().initialize ();
43
+ if (LunaFirebase .isSupported) await LunaFirebase ().initialize ();
44
+ LunaTheme ().initialize ();
45
+ if (LunaWindowManager .isSupported) await LunaWindowManager ().initialize ();
46
+ if (LunaNetwork .isSupported) LunaNetwork ().initialize ();
47
+ if (LunaImageCache .isSupported) LunaImageCache ().initialize ();
48
+ LunaRouter ().initialize ();
49
+ if (LunaInAppPurchase .isSupported) LunaInAppPurchase ().initialize ();
50
+ await LunaLocalization ().initialize ();
51
+ await LunaMemoryStore ().initialize ();
52
+ }
53
+
45
54
class LunaBIOS extends StatelessWidget {
46
55
const LunaBIOS ({
47
56
Key ? key,
0 commit comments