From cfd38211a22c2e89acec4559f2e54533b84f4fbe Mon Sep 17 00:00:00 2001 From: Thatsaphorn Atchariyaphap Date: Mon, 22 Sep 2025 19:26:39 +0200 Subject: [PATCH] Convert `registerDefaultServices` to `async` and update service initialization --- finlog_app/app/lib/main.dart | 2 +- finlog_app/fluttery/lib/fluttery.dart | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/finlog_app/app/lib/main.dart b/finlog_app/app/lib/main.dart index 6ccb02f..9ee6bc6 100644 --- a/finlog_app/app/lib/main.dart +++ b/finlog_app/app/lib/main.dart @@ -8,7 +8,7 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); // any services - App.registerDefaultServices(); + await App.registerDefaultServices(); final logger = App.service(); logger.debug("[MAIN] Registered all default services"); diff --git a/finlog_app/fluttery/lib/fluttery.dart b/finlog_app/fluttery/lib/fluttery.dart index be6a583..cf38d0e 100644 --- a/finlog_app/fluttery/lib/fluttery.dart +++ b/finlog_app/fluttery/lib/fluttery.dart @@ -30,12 +30,11 @@ class App { } /// Registers the default services required by the application. - static void registerDefaultServices() { + static Future registerDefaultServices() async { registerService(() => LoggerImpl()); - SharedPreferences.getInstance().then((instance) { - registerService(() => PreferencesImpl(instance: instance)); - }); + final prefs = await SharedPreferences.getInstance(); + registerService(() => PreferencesImpl(instance: prefs)); registerService(() => SecureStorageImpl()); }