-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.dart
72 lines (61 loc) · 1.93 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
64
65
66
67
68
69
70
71
72
/*
*
* * Copyright (c) 2024 Mindful (https://github.com/akaMrNagar/Mindful)
* * Author : Pawan Nagar (https://github.com/akaMrNagar)
* *
* * This source code is licensed under the GPL-2.0 license license found in the
* * LICENSE file in the root directory of this source tree.
*
*/
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mindful/core/services/bg_executor_service.dart';
import 'package:mindful/core/services/crash_log_service.dart';
import 'package:mindful/core/services/drift_db_service.dart';
import 'package:mindful/core/services/method_channel_service.dart';
import 'package:mindful/mindful_app.dart';
/// Dart background
@pragma('vm:entry-point')
Future<void> initBgExecutorService() async {
WidgetsFlutterBinding.ensureInitialized();
await BgExecutorService.instance.init();
}
/// Flutter main app
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
/// Initialize method channel
await MethodChannelService.instance.init();
/// Initialize drift Database
await DriftDbService.instance.init();
/// Initialize local crashlytics
await CrashLogService.instance.init();
FlutterError.onError = (errorDetails) {
CrashLogService.instance.recordCrashError(
errorDetails.exception.toString(),
errorDetails.stack.toString(),
);
if (kDebugMode) {
FlutterError.presentError(errorDetails);
}
};
PlatformDispatcher.instance.onError = (error, stack) {
CrashLogService.instance.recordCrashError(
error.toString(),
stack.toString(),
);
return true;
};
/// Scale app from edge-edge behind system ui
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.edgeToEdge,
overlays: [SystemUiOverlay.top],
);
/// run main app
runApp(
const ProviderScope(
child: MindfulApp(),
),
);
}