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)
- feat: Static functions for routes on screens HOT 4
- auto_route fragment support HOT 5
- Function pushAll won't work on WEB HOT 1
- Navigate and other functions are way slower then they should be HOT 8
- Error when using 8.14 HOT 11
- Creating feature flow using auto_route HOT 5
- When I navigate to the same route a second time, the page doesn't refresh. HOT 4
- Replacing go_router with auto_route in widget tests HOT 4
- Overide a route HOT 2
- Manage System back button with Auto route with alternative way HOT 2
- Inherited Path Parameters aren't working HOT 3
- how to use outer route (parent) inside the inner the route in nested routing HOT 3
- How can i logout a use when my refresh token is expired? HOT 1
- reevaluateListenable does not call AutoRouteGuard.onNavigation() HOT 6
- How to get result in navigation observer HOT 4
- Route Page does not get generated for a few pages HOT 2
- Cold start app by deep link cause white screen HOT 4
- "PostRouteArgs can not be null because the corresponding page has a required parameter" as soon as I try to select a widget in WidgetInspector HOT 10
- Integration Testing using `Patrol` HOT 1
- Auto Router Declarative do not trigger initial route transition animation HOT 7
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.