Skip to content

Commit

Permalink
Tweak initialization of onboardingRepositoryProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
bizz84 committed Jan 6, 2025
1 parent a828730 commit b7e4d7d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/src/features/onboarding/data/onboarding_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class OnboardingRepository {

@Riverpod(keepAlive: true)
Future<OnboardingRepository> onboardingRepository(Ref ref) async {
return OnboardingRepository(
ref.watch(sharedPreferencesProvider).requireValue);
final sharedPreferences = await ref.watch(sharedPreferencesProvider.future);
return OnboardingRepository(sharedPreferences);
}
3 changes: 0 additions & 3 deletions lib/src/routing/app_startup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -12,14 +11,12 @@ part 'app_startup.g.dart';
Future<void> 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);
}

Expand Down

0 comments on commit b7e4d7d

Please sign in to comment.