-
I'm using the auto_route package. It has route guards functionality. I wonder if there is a way how to get the logged user data in the route guard? class MobileRouteGuard extends AutoRouteGuard {
@override
void onNavigation(NavigationResolver resolver, StackRouter router) {
final user = ???.read(currenUserController).state;
if (user == null) {
router.navigate(const LogInRoute());
} else {
resolver.next();
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
YuriHeiko
Sep 19, 2021
Replies: 1 comment
-
Looks like I found the answer |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
YuriHeiko
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like I found the answer
final user = router.navigatorKey.currentContext!.read(currentUserController).state;