From 6ad66f363e3fe956d1371cdcf9fe7df569066609 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Mon, 22 Jan 2024 15:45:21 +0000 Subject: [PATCH] Invalidate the onboardingRepositoryProvider inside the onDispose callback of the appStartupProvider --- lib/src/app_startup.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/app_startup.dart b/lib/src/app_startup.dart index 15bfcf0b..b4dfe70d 100644 --- a/lib/src/app_startup.dart +++ b/lib/src/app_startup.dart @@ -10,6 +10,10 @@ part 'app_startup.g.dart'; @Riverpod(keepAlive: true) Future appStartup(AppStartupRef ref) async { + ref.onDispose(() { + // ensure dependent providers are disposed as well + ref.invalidate(onboardingRepositoryProvider); + }); // await for all initialization code to be complete before returning await Future.wait([ // Firebase init @@ -32,10 +36,7 @@ class AppStartupWidget extends ConsumerWidget { loading: () => const AppStartupLoadingWidget(), error: (e, st) => AppStartupErrorWidget( message: e.toString(), - onRetry: () { - ref.invalidate(onboardingRepositoryProvider); - ref.invalidate(appStartupProvider); - }, + onRetry: () => ref.invalidate(appStartupProvider), ), ); }