@@ -23,71 +23,62 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
23
23
);
24
24
}
25
25
26
- void main () {
27
- runZonedGuarded (
28
- () async {
29
- WidgetsFlutterBinding .ensureInitialized ();
26
+ Future <void > main () async {
27
+ WidgetsFlutterBinding .ensureInitialized ();
30
28
31
- final ByteData data = await PlatformAssetBundle ().load (
32
- 'assets/ca/twca_nsysu.cer' ,
33
- );
34
- SecurityContext .defaultContext.setTrustedCertificatesBytes (
35
- data.buffer.asUint8List (),
36
- );
29
+ final ByteData data = await PlatformAssetBundle ().load (
30
+ 'assets/ca/twca_nsysu.cer' ,
31
+ );
32
+ SecurityContext .defaultContext.setTrustedCertificatesBytes (
33
+ data.buffer.asUint8List (),
34
+ );
37
35
38
- await Preferences .init (
39
- key: Constants .key,
40
- iv: Constants .iv,
41
- );
36
+ await Preferences .init (
37
+ key: Constants .key,
38
+ iv: Constants .iv,
39
+ );
42
40
43
- timeago.setLocaleMessages ('zh-TW' , timeago.ZhMessages ());
44
- timeago.setLocaleMessages ('en-US' , timeago.EnMessages ());
45
- if (! kIsWeb && Platform .isAndroid) {
46
- //TODO: 改使用原生方式限制特定網域
47
- HttpOverrides .global = MyHttpOverrides ();
48
- }
49
- final String currentVersion =
50
- Preferences .getString (Constants .prefCurrentVersion, '0' );
51
- if (int .parse (currentVersion) < 700 ) _migrate700 ();
52
- FirebaseMessaging .onBackgroundMessage (
53
- _firebaseMessagingBackgroundHandler,
54
- );
55
- if (FirebaseUtils .isSupportCore ||
56
- Platform .isWindows ||
57
- Platform .isLinux) {
58
- await Firebase .initializeApp (
59
- options: DefaultFirebaseOptions .currentPlatform,
60
- );
61
- }
62
- if (kDebugMode) {
63
- if (FirebaseCrashlyticsUtils .isSupported) {
64
- await FirebaseCrashlytics .instance
65
- .setCrashlyticsCollectionEnabled (false );
66
- }
67
- if (FirebasePerformancesUtils .isSupported) {
68
- await FirebasePerformance .instance
69
- .setPerformanceCollectionEnabled (false );
70
- }
71
- }
72
- if (! kIsWeb &&
73
- (Platform .isWindows || Platform .isMacOS || Platform .isLinux)) {
74
- GoogleSignInDart .register (
75
- clientId: SdkConstants .googleSignInDesktopClientId,
76
- );
77
- }
78
- if (! kDebugMode && FirebaseCrashlyticsUtils .isSupported) {
79
- FlutterError .onError = FirebaseCrashlytics .instance.recordFlutterError;
80
- }
81
- runApp (MyApp ());
82
- },
83
- (Object e, StackTrace s) {
84
- if (! kDebugMode && FirebaseCrashlyticsUtils .isSupported) {
85
- FirebaseCrashlytics .instance.recordError (e, s);
86
- } else {
87
- throw e;
88
- }
89
- },
41
+ timeago.setLocaleMessages ('zh-TW' , timeago.ZhMessages ());
42
+ timeago.setLocaleMessages ('en-US' , timeago.EnMessages ());
43
+ if (! kIsWeb && Platform .isAndroid) {
44
+ //TODO: 改使用原生方式限制特定網域
45
+ HttpOverrides .global = MyHttpOverrides ();
46
+ }
47
+ final String currentVersion =
48
+ Preferences .getString (Constants .prefCurrentVersion, '0' );
49
+ if (int .parse (currentVersion) < 700 ) _migrate700 ();
50
+ FirebaseMessaging .onBackgroundMessage (
51
+ _firebaseMessagingBackgroundHandler,
90
52
);
53
+ if (FirebaseUtils .isSupportCore || Platform .isWindows || Platform .isLinux) {
54
+ await Firebase .initializeApp (
55
+ options: DefaultFirebaseOptions .currentPlatform,
56
+ );
57
+ }
58
+ if (kDebugMode) {
59
+ if (FirebaseCrashlyticsUtils .isSupported) {
60
+ await FirebaseCrashlytics .instance.setCrashlyticsCollectionEnabled (false );
61
+ }
62
+ if (FirebasePerformancesUtils .isSupported) {
63
+ await FirebasePerformance .instance.setPerformanceCollectionEnabled (false );
64
+ }
65
+ }
66
+ if (! kIsWeb && (Platform .isWindows || Platform .isMacOS || Platform .isLinux)) {
67
+ GoogleSignInDart .register (
68
+ clientId: SdkConstants .googleSignInDesktopClientId,
69
+ );
70
+ }
71
+
72
+ if (! kDebugMode && FirebaseCrashlyticsUtils .isSupported) {
73
+ FlutterError .onError = (FlutterErrorDetails errorDetails) {
74
+ FirebaseCrashlytics .instance.recordFlutterFatalError (errorDetails);
75
+ };
76
+ PlatformDispatcher .instance.onError = (Object error, StackTrace stack) {
77
+ FirebaseCrashlytics .instance.recordError (error, stack);
78
+ return true ;
79
+ };
80
+ }
81
+ runApp (MyApp ());
91
82
}
92
83
93
84
void _migrate700 () {
0 commit comments