-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
63 lines (54 loc) · 1.6 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
59
60
61
62
63
import 'dart:developer' as developer;
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart' show WidgetsFlutterBinding, runApp;
import 'package:logging/logging.dart' show Level, LogRecord, Logger;
import 'package:provider/provider.dart' show MultiProvider, Provider;
import 'app.dart';
import 'data/settings.dart';
import 'di.dart';
import 'firebase_options.dart';
import 'utils.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Setup Firebase
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Setup Logger
Logger.root
..level = Level.ALL
..onRecord.listen(_onRecord);
// Setup DI
configureDependencies();
// Init Settings
final settings = await Settings.create();
// Run App
runApp(
MultiProvider(
providers: [
Provider<Settings>.value(value: settings),
],
child: const App(),
),
);
}
/// [Logger] log callback.
void _onRecord(final LogRecord record) {
if (kDebugMode) {
developer.log(
record.message,
name: record.loggerName,
time: record.time,
sequenceNumber: record.sequenceNumber,
level: record.level.value,
zone: record.zone,
error: record.error,
stackTrace: record.stackTrace,
);
} else {
// TODO Collect also some Settings (acceptedPrivacyPolicyVersion, acceptedTermsOfServiceVersion) on app init and on change
FirebaseCrashlytics.instance.log(formatCrashlyticsLog(record));
}
}