GithubHelp home page GithubHelp logo

Comments (5)

Milad-Akarie avatar Milad-Akarie commented on May 29, 2024 1

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.

Ortes avatar Ortes commented on May 29, 2024

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.

Milad-Akarie avatar Milad-Akarie commented on May 29, 2024

@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.

Ortes avatar Ortes commented on May 29, 2024

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.

Milad-Akarie avatar Milad-Akarie commented on May 29, 2024

@Ortes you can try the brand new deepLinkTransformer
or deepLinkBuilder

from auto_route_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.