From 1f6a7f59c1a6d908ee56ec3ddff9442502bdece3 Mon Sep 17 00:00:00 2001 From: armanddidierjean <95971503+armanddidierjean@users.noreply.github.com> Date: Sat, 27 Apr 2024 21:38:02 +0200 Subject: [PATCH 1/2] Let logger init return itself to be able to chain logger methods --- lib/tools/logs/logger.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tools/logs/logger.dart b/lib/tools/logs/logger.dart index bc7398e4c..db08e63b9 100644 --- a/lib/tools/logs/logger.dart +++ b/lib/tools/logs/logger.dart @@ -15,7 +15,7 @@ class Logger { init(); } - void init() async { + Future init() async { if (kIsWeb) { loggerOutput = PrintLoggerOutput(); await loggerOutput!.init(); @@ -23,6 +23,7 @@ class Logger { loggerOutput = FileLoggerOutput(); await loggerOutput!.init(); } + return this; } void writeLog(Log log) { From 97fe30f551c424f0faf399a1ed5db627e7b7ad17 Mon Sep 17 00:00:00 2001 From: armanddidierjean <95971503+armanddidierjean@users.noreply.github.com> Date: Sat, 27 Apr 2024 21:38:43 +0200 Subject: [PATCH 2/2] Try to init firebase and log on error --- lib/main.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 47479db29..0dc125b5b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,6 +16,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:myecl/router.dart'; import 'package:myecl/service/tools/setup.dart'; import 'package:myecl/tools/functions.dart'; +import 'package:myecl/tools/logs/logger.dart'; import 'package:myecl/tools/plausible/plausible_observer.dart'; import 'package:myecl/tools/ui/layouts/app_template.dart'; import 'package:qlevar_router/qlevar_router.dart'; @@ -30,8 +31,14 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); if (!kIsWeb) { - await Firebase.initializeApp(); - FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); + try { + await Firebase.initializeApp(); + FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); + } on FirebaseException catch (e) { + Logger().init().then( + (logger) => logger.warning("Could not init Firebase: ${e.message}"), + ); + } } await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); runApp(const ProviderScope(child: MyApp()));