diff --git a/lib/src/routing/app_router.dart b/lib/src/routing/app_router.dart index 6cec69a..8fc04f9 100644 --- a/lib/src/routing/app_router.dart +++ b/lib/src/routing/app_router.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:riverpod/riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; -import 'package:starter_architecture_flutter_firebase/src/routing/app_startup.dart'; import 'package:starter_architecture_flutter_firebase/src/features/authentication/data/firebase_auth_repository.dart'; import 'package:starter_architecture_flutter_firebase/src/features/authentication/presentation/custom_profile_screen.dart'; import 'package:starter_architecture_flutter_firebase/src/features/authentication/presentation/custom_sign_in_screen.dart'; @@ -43,18 +42,12 @@ enum AppRoute { @riverpod GoRouter goRouter(Ref ref) { - // rebuild GoRouter when app startup state changes - final appStartupState = ref.watch(appStartupProvider); final authRepository = ref.watch(authRepositoryProvider); return GoRouter( initialLocation: '/signIn', navigatorKey: _rootNavigatorKey, debugLogDiagnostics: true, redirect: (context, state) { - // If the app is still initializing, show the /startup route - if (appStartupState.isLoading || appStartupState.hasError) { - return '/startup'; - } final onboardingRepository = ref.read(onboardingRepositoryProvider).requireValue; final didCompleteOnboarding = onboardingRepository.isOnboardingComplete(); @@ -69,14 +62,11 @@ GoRouter goRouter(Ref ref) { } final isLoggedIn = authRepository.currentUser != null; if (isLoggedIn) { - if (path.startsWith('/startup') || - path.startsWith('/onboarding') || - path.startsWith('/signIn')) { + if (path.startsWith('/onboarding') || path.startsWith('/signIn')) { return '/jobs'; } } else { - if (path.startsWith('/startup') || - path.startsWith('/onboarding') || + if (path.startsWith('/onboarding') || path.startsWith('/jobs') || path.startsWith('/entries') || path.startsWith('/account')) { @@ -87,16 +77,6 @@ GoRouter goRouter(Ref ref) { }, refreshListenable: GoRouterRefreshStream(authRepository.authStateChanges()), routes: [ - GoRoute( - path: '/startup', - pageBuilder: (context, state) => NoTransitionPage( - child: AppStartupWidget( - // * This is just a placeholder - // * The loaded route will be managed by GoRouter on state change - onLoaded: (_) => const SizedBox.shrink(), - ), - ), - ), GoRoute( path: '/onboarding', name: AppRoute.onboarding.name, diff --git a/lib/src/routing/app_startup.dart b/lib/src/routing/app_startup.dart index 435e75a..fa413ec 100644 --- a/lib/src/routing/app_startup.dart +++ b/lib/src/routing/app_startup.dart @@ -13,6 +13,9 @@ Future appStartup(Ref ref) async { // ensure dependent providers are disposed as well 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(onboardingRepositoryProvider.future); }