Comments (8)
nope. I had to add a guard on specific routes rather than global one
from auto_route_library.
Oh as I was typing out my solution I realized the difference between my global guard that's not working and local. In my local one I'm using router.replaceAll([RouteToShow()])
instead of resolver.redirect(RouteToShow())
.
Just tried to use router.replaceAll
in my global and it seems to be working fine.
The only issue is having to also check for root but honestly that's not a big deal.
from auto_route_library.
router.current is not the route being intercepted by guard, resolver.route is.
from auto_route_library.
No the docs seems to be ok. Just tested with resolver.route.name
and it works like charm.
my bad :)
and thanks!
from auto_route_library.
Have you solved this? I got the same problem, for me it causes blank screen and an exception on the console, here is my issue #1818
from auto_route_library.
nope. I had to add a guard on specific routes rather than global one
Would you mind sharing your temporary solution? I did try to assign them manually by separating the guard in its own class like tis:
class AuthGuard extends AutoRouteGuard {
AuthGuard({
required this.authState,
}) : super();
final AuthStateNotifer authState;
@override
void onNavigation(NavigationResolver resolver, StackRouter router) {
final isLoginRoute = router.current.name == SignInRoute.name;
final isSignUpRoute = router.current.name == SignUpRoute.name;
final isAuthPage = isLoginRoute || isSignUpRoute;
if (authState.isLogged && isAuthPage) {
resolver.redirect(const HomeRoute());
} else if (authState.isLogged && !isAuthPage) {
resolver.next(true);
} else if (!authState.isLogged && isAuthPage) {
resolver.next(true);
} else if (router.current.name == 'Root') {
resolver.next(true);
} else {
resolver.redirect(const SignInRoute());
}
}
}
Like this it works, but it concerns me that I have to check on that specific route Root
otherwise it causes the onNavigation to be triggered infinitly.
from auto_route_library.
well it's official now, I can't read it seems
from auto_route_library.
Or maybe whoever wrote the docs made a mistake...
from auto_route_library.
Related Issues (20)
- pushing to same screen issue
- New Xcode error out of the blue HOT 1
- [Bug] - Using the same Screen as Two routes results into an exception
- [QUESTION] Why RouteMatch operator == doesn't have args?
- AutoTabsRouter.pageView sibling views defaults to path '' HOT 2
- Cannot navigate to child route with @PathParam.inherit("param"). HOT 13
- Issues Implementing Custom rebuildAll and popAllAndPushAll Methods in auto_route HOT 3
- deepLinkBuilder && doubling element's tree HOT 1
- Pushing to sub-page in another tab and maintaining history? HOT 5
- deepLinkBuilder Not working on Production HOT 1
- Default function argument value has no import prefix
- Automatically back when use CustomRoute with swipe for back HOT 1
- Unable to Set Custom Transition Duration While Maintaining iOS Swipe Back Gesture HOT 2
- browser buttons navigation in flutter web HOT 1
- Got an error when navigation back web button with nested route HOT 5
- PopScope, Function(bool)? onPopInvoked, boolean value is always true for web even when canPop is false
- Route get reset after keyboard appears HOT 1
- Bad state: Future already completed HOT 2
- Blank screen when first opening the app HOT 3
- feat: Static getters for routes on screens
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto_route_library.