From b7e4d7d2747b8aadb76a1f89cb66a000a3ea7810 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Mon, 6 Jan 2025 09:42:44 +0000 Subject: [PATCH] Tweak initialization of onboardingRepositoryProvider --- lib/src/features/onboarding/data/onboarding_repository.dart | 4 ++-- lib/src/routing/app_startup.dart | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/src/features/onboarding/data/onboarding_repository.dart b/lib/src/features/onboarding/data/onboarding_repository.dart index 11b12569..acd807c8 100644 --- a/lib/src/features/onboarding/data/onboarding_repository.dart +++ b/lib/src/features/onboarding/data/onboarding_repository.dart @@ -21,6 +21,6 @@ class OnboardingRepository { @Riverpod(keepAlive: true) Future onboardingRepository(Ref ref) async { - return OnboardingRepository( - ref.watch(sharedPreferencesProvider).requireValue); + final sharedPreferences = await ref.watch(sharedPreferencesProvider.future); + return OnboardingRepository(sharedPreferences); } diff --git a/lib/src/routing/app_startup.dart b/lib/src/routing/app_startup.dart index 8dfed3c5..e3639802 100644 --- a/lib/src/routing/app_startup.dart +++ b/lib/src/routing/app_startup.dart @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:starter_architecture_flutter_firebase/src/constants/app_sizes.dart'; import 'package:starter_architecture_flutter_firebase/src/features/onboarding/data/onboarding_repository.dart'; -import 'package:starter_architecture_flutter_firebase/src/utils/shared_preferences_provider.dart'; part 'app_startup.g.dart'; @@ -12,14 +11,12 @@ part 'app_startup.g.dart'; Future appStartup(Ref ref) async { ref.onDispose(() { // ensure dependent providers are disposed as well - ref.invalidate(sharedPreferencesProvider); ref.invalidate(onboardingRepositoryProvider); }); // Uncomment this to test that URL-based navigation and deep linking works // even when there's a delay in the app startup logic // await Future.delayed(Duration(seconds: 1)); // await for all initialization code to be complete before returning - await ref.watch(sharedPreferencesProvider.future); await ref.watch(onboardingRepositoryProvider.future); }