forked from FlutterKaigi/conference-app-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
58 lines (51 loc) · 1.86 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import 'package:conference_2023/app.dart';
import 'package:conference_2023/model/messaging.dart';
import 'package:conference_2023/model/remote_config.dart';
import 'package:conference_2023/model/shared_preferences.dart';
import 'package:conference_2023/util/font_license.dart';
import 'package:conference_2023/util/provider_state_logger.dart';
import 'package:conference_2023/util/web/firebase_options_web.dart';
import 'package:conference_2023/util/web/path_strategy.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
updatePathStrategy();
await Firebase.initializeApp(
options: firebaseOptionsWeb,
);
// Non-async exceptions
FlutterError.onError = (errorDetails) {
FirebaseCrashlytics.instance.recordFlutterError(errorDetails);
};
// Async exceptions
PlatformDispatcher.instance.onError = (error, stack) {
FirebaseCrashlytics.instance.recordError(error, stack);
return true;
};
/// initialize firebase apps
await initFirebaseRemoteConfig();
await initFirebaseMessaging();
fontLicenses();
final pref = await SharedPreferences.getInstance();
runApp(
ProviderScope(
overrides: [
/// This is a trick to get instances of SharedPreferences synchronously.
/// Note: Because of this trick, [sharedPreferencesProvider] behaves
/// differently from a normal [Provider].
sharedPreferencesProvider.overrideWithValue(pref),
],
observers: kDebugMode
? [
ProviderStateLogger(),
]
: null,
child: const App(),
),
);
}