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)
- browser refresh issue HOT 1
- App crashes when trying to navigate from modal, which is animating. HOT 1
- Udpate documentation for Autoroute Declaritive Routing HOT 1
- Navigate Function causes clearing for path params HOT 1
- AutoLeadingButton custom semantic label
- onNavigation guard causes Stack Overflow
- In NESTED NAVIGATION the pages overlap in the transition HOT 1
- infinite loop on context.router.pop()
- AutoTabsRouter testecase fail. HOT 4
- Initial page created when homeIndex is set differently
- add shallow routing
- Functionality to control route changes
- Functionality to control route changes HOT 4
- Unhandled Exception: type 'AutoRoutePage<dynamic>' is not a subtype of type 'AutoRoutePage<Object>' in type HOT 2
- Inherited params not working and wrong navigation HOT 1
- Generator uses absolute paths which generates an error in my app
- Route back to initial splash page every time I save. HOT 3
- Infinite loop in context.router.push() HOT 2
- Deep link navigation with AutoTabsScaffold; Consider making PlatformDeepLink constructor public
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.