Comments (5)
you can do something like this
AutoRoute(
page: HomeRoute.page,
path: '/home',
guards: [
AutoRouteGuard.redirect(
(resolver) {
return resolver.route.args == null ? MyRedirectRoute() : null;
},
),
],
)
if you're working with paths use AutoRouteGuard.redirectPath
from auto_route_library.
Thanks I will try but I do need to add this guard for all routes with arguments ? Is there a way to have them all follow this redirect ?
Moreover I was messing around with my app and I realized I get the same problem for misswritten url (errors in the path). Is there a 404 error like behavior ?
Not that my users would need to craft urls by hand but if somehow the link get messed up I think that it would be nice to have some behavior than a white screen (it is the behavior of my app in production for path misspelled and args parsing error)
from auto_route_library.
@Ortes you can use a global guard, read more here
for 404 page you add a wild card path at the end of your routes list
AutoRoute(path: '*', page: NotFoundRoute.page)
or redirect to home
RedirectRoute(path: '*', redirectTo: '/')
from auto_route_library.
Thanks for the reply, 404 page fits my need indeed.
For the global guard could you give an example I do not see how to do it because the global guard would not know what args correspond to what page exept for switch through them all is this the only way ?
from auto_route_library.
@Ortes you can try the brand new deepLinkTransformer
or deepLinkBuilder
from auto_route_library.
Related Issues (20)
- Back button on Android closes App on Sub route
- Implement Persist Navigation State Feature
- Back navigation blank issue still persists in 8.1.1 HOT 1
- removeWhere removes the wrong route HOT 1
- PopScope not working on web browser back button HOT 1
- How to add new Nested Navigation Tab dynamically?
- Deeplink getting called multiple times HOT 12
- Child pages are not rendered after exiting a nested initial page with the back gesture and launching from the Android launcher. HOT 9
- Regression on StackRouter.popAndPushAll()
- Cannot reload route with callback parameter HOT 1
- [BUG] deeplinkBuilder is not called
- Codegen can't find widgets, they need to be imported into the app_router file HOT 1
- Inconsistent ReevaluateListenable Behavior on Web vs. Android
- didPop & didPopNext not called
- IOS swipe back make TextField not focus when tab on TextField when app build with flutter 3.22 HOT 2
- CustomRoute() transition gets overridden by defaultRouteType
- Handling of back navigation in nested routes, ignored PopScope HOT 2
- pushing to same screen issue
- New Xcode error out of the blue
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.