I have a user state notifier that manages login and logout. If the user is logged in when the app starts I redirect to a logged in route. Because it needs to get the user from hive it is not ready in the time. How can I wait for the state notifier to do its thing before runApp starts the app?
this is what it looks like
VGuard(
afterEnter: (BuildContext context, __, ___) async {
String currentPath = VRouter.of(context).path;
/// Wait for state notifier to not be "UserInitial"
// If path is base
if (currentPath == '/') {
// Redirect
if (userStateNotifier is UserLoggedOut) {
context.vRouter.to('/logged-out');
} else if (userStateNotifier is UserLoggedIn) {
context.vRouter.to('/logged-in');
}
}
},
stackedRoutes: [
VWidget(
path: '/',
widget: const SplashScreen(),
),
],
),