@@ -13,35 +13,35 @@ import 'package:bugaoshan/services/window_state_service.dart';
1313import 'package:system_theme/system_theme.dart' ;
1414
1515Future <void > main () async {
16- await runZonedGuarded (
17- () async {
18- WidgetsFlutterBinding .ensureInitialized ();
19- if (! kIsWeb) {
20- DartPluginRegistrant .ensureInitialized ();
21- if (_isDesktopPlatform) {
22- sqfliteFfiInit ();
23- databaseFactory = databaseFactoryFfi;
24- }
25- }
26- configureDependencies ();
27- await ensureBasicDependencies ();
16+ try {
17+ await _initializeApp ();
18+ runApp (MyApp ());
19+ } catch (error, stackTrace) {
20+ debugPrint ('Startup error: $error \n $stackTrace ' );
21+ runApp (const _StartupErrorApp ());
22+ }
23+ }
2824
29- // 桌面端记住窗口位置和大小,下次启动时恢复
30- if (! kIsWeb && _isDesktopPlatform) {
31- await WindowStateService .create (getIt <SharedPreferences >());
32- }
25+ Future <void > _initializeApp () async {
26+ WidgetsFlutterBinding .ensureInitialized ();
27+ if (! kIsWeb) {
28+ DartPluginRegistrant .ensureInitialized ();
29+ if (_isDesktopPlatform) {
30+ sqfliteFfiInit ();
31+ databaseFactory = databaseFactoryFfi;
32+ }
33+ }
34+ configureDependencies ();
35+ await ensureBasicDependencies ();
3336
34- // 获取系统主题颜色
35- SystemTheme .fallbackColor = Colors .blue;
36- await SystemTheme .accentColor.load ();
37+ // 桌面端记住窗口位置和大小,下次启动时恢复
38+ if (! kIsWeb && _isDesktopPlatform) {
39+ await WindowStateService .create (getIt <SharedPreferences >());
40+ }
3741
38- runApp (MyApp ());
39- },
40- (error, stackTrace) {
41- debugPrint ('Startup error: $error \n $stackTrace ' );
42- runApp (const _StartupErrorApp ());
43- },
44- );
42+ // 获取系统主题颜色
43+ SystemTheme .fallbackColor = Colors .blue;
44+ await SystemTheme .accentColor.load ();
4545}
4646
4747bool get _isDesktopPlatform {
0 commit comments