|
@@ -42,41 +42,46 @@ void main() {
|
|
|
}
|
|
|
|
|
|
Future<void> initialize() async {
|
|
|
- final getIt = GetIt.instance;
|
|
|
- var isWeb = PlatformUtils.isWeb;
|
|
|
- if (isWeb) {
|
|
|
- Logger.client = ColorizeLoggerClient();
|
|
|
- Logger.info('The first log in web');
|
|
|
- } else {
|
|
|
- if (Logger.isReleaseMode()) {
|
|
|
- /// use file
|
|
|
- Directory directory = await getApplicationDocumentsDirectory();
|
|
|
- final currentDate = DateTime.now();
|
|
|
- final fileName =
|
|
|
- '${currentDate.year}-${currentDate.month}-${currentDate.day}-logs.txt';
|
|
|
- Logger.client = FileLoggerClient(filePath: '${directory.path}/$fileName');
|
|
|
+ try {
|
|
|
+ final getIt = GetIt.instance;
|
|
|
+ var isWeb = PlatformUtils.isWeb;
|
|
|
+ if (isWeb) {
|
|
|
+ Logger.client = ColorizeLoggerClient();
|
|
|
+ Logger.info('The first log in web');
|
|
|
} else {
|
|
|
- Logger.client = ColorizeLoggerClient(); //for debug
|
|
|
+ if (Logger.isReleaseMode()) {
|
|
|
+ /// use file
|
|
|
+ Directory directory = await getApplicationDocumentsDirectory();
|
|
|
+ final currentDate = DateTime.now();
|
|
|
+ final fileName =
|
|
|
+ '${currentDate.year}-${currentDate.month}-${currentDate.day}-logs.txt';
|
|
|
+ Logger.client =
|
|
|
+ FileLoggerClient(filePath: '${directory.path}/$fileName');
|
|
|
+ } else {
|
|
|
+ Logger.client = ColorizeLoggerClient(); //for debug
|
|
|
+ }
|
|
|
+ Logger.info('The first log in app');
|
|
|
+
|
|
|
+ /// use sentry
|
|
|
+ // await SentryFlutter.init(
|
|
|
+ // (options) {
|
|
|
+ // options.dsn = 'https://example@sentry.io/add-your-dsn-here';
|
|
|
+ // },
|
|
|
+ // );
|
|
|
+ // Logger.client = SentryLoggerClient();
|
|
|
+ var dbServcie = new DatabaseService();
|
|
|
+ getIt.registerSingleton<DatabaseService>(dbServcie);
|
|
|
+ await dbServcie.initialize();
|
|
|
}
|
|
|
- Logger.info('The first log in app');
|
|
|
|
|
|
- /// use sentry
|
|
|
- // await SentryFlutter.init(
|
|
|
- // (options) {
|
|
|
- // options.dsn = 'https://example@sentry.io/add-your-dsn-here';
|
|
|
- // },
|
|
|
- // );
|
|
|
- // Logger.client = SentryLoggerClient();
|
|
|
- var dbServcie = new DatabaseService();
|
|
|
- getIt.registerSingleton<DatabaseService>(dbServcie);
|
|
|
- await dbServcie.initialize();
|
|
|
+ getIt.registerSingleton<LocalStorageService>(LocalStorageService(isWeb));
|
|
|
+ getIt.registerSingleton<ApiTestService>(ApiTestService());
|
|
|
+ getIt.registerSingleton<UserService>(UserService());
|
|
|
+ getIt.registerSingleton<ConsultationService>(ConsultationService());
|
|
|
+ runApp(const MyApp());
|
|
|
+ } catch (ex) {
|
|
|
+ Logger.error("initialize exception:$ex");
|
|
|
}
|
|
|
-
|
|
|
- getIt.registerSingleton<LocalStorageService>(LocalStorageService(isWeb));
|
|
|
- getIt.registerSingleton<ApiTestService>(ApiTestService());
|
|
|
- getIt.registerSingleton<UserService>(UserService());
|
|
|
- getIt.registerSingleton<ConsultationService>(ConsultationService());
|
|
|
- runApp(const MyApp());
|
|
|
}
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|