Skip to content

Support RegExp in path GoRoute #143070

Open
Open

Description

@jimpatrick

Use case

Navigate packages are made to make it easier to handle routing, and now GoRouter has completely ignored this principle by making it difficult and removing a variety of commonly used methods.
In the Velocity_x package, I have the possibility to insert the route as a RegExp, and now this is not possible in GoRouter, and only the
parameters are handled through the RegExp!

Expected RegExp path:

static const resetPasswordScreen = "\/(resetPasswordProfile|profile)(\/password)?";

The above RegExp should support the following four paths:

---> resetPasswordScreen = "/resetPasswordProfile"
---> resetPasswordScreen = "/resetPasswordProfile/password"
---> resetPasswordScreen = "/profile"
---> resetPasswordScreen = "/profile/password"
GoRoute(
  name: 'resetPasswordScreen',
  path: resetPasswordScreen,
  parentNavigatorKey: rootNavigatorKey,
  pageBuilder: (context, state) => _transitionPageBuilder(context, state, const ResetPasswordProfile()),
)

I want to know this feature exist or not, and if not, can you implement it?

Proposal

static const resetPasswordScreen = "\/(resetPasswordProfile|profile)(\/password)?";
GoRoute(
  name: 'resetPasswordScreen',
  path: resetPasswordScreen,
  parentNavigatorKey: rootNavigatorKey,
  pageBuilder: (context, state) => _transitionPageBuilder(context, state, const ResetPasswordProfile()),
)

Activity

  1. darshankawar commented on Feb 7, 2024

    @darshankawar
    Member

    @jimpatrick
    Can you take a look at this and see if it helps in your case or not ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 7, 2024
  3. jimpatrick commented on Feb 9, 2024

    @jimpatrick
    Author

    @jimpatrick Can you take a look at this and see if it helps in your case or not ?

    No, as I said, only parameters can be checked by RegExp in GoRouter, and this is different from my case.

    Please check path in GoRouter package.
    Codes about RegExp in GoRouter package

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 9, 2024
  5. darshankawar commented on Feb 12, 2024

    @darshankawar
    Member

    Thanks for the feedback.

  6. added
    c: new featureNothing broken; request for a new capability
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    and removed
    in triagePresently being triaged by the triage team
    on Feb 12, 2024
  7. chunhtai commented on Apr 25, 2024

    @chunhtai
    Contributor

    I think you can workaround this by define two goRoute
    GoRoute(/:id(resetPasswordProfile|profile))
    GoRoute(/:id(resetPasswordProfile|profile)/password)

  8. jimpatrick commented on Jul 31, 2024

    @jimpatrick
    Author

    I think you can workaround this by define two goRoute GoRoute(/:id(resetPasswordProfile|profile)) GoRoute(/:id(resetPasswordProfile|profile)/password)

    Good idea but it's not perfect! Path parameter in GoRouter class should support RegEx :)

  9. YukiAttano commented on Oct 30, 2025

    @YukiAttano

    I guess this issue i already fixed?
    I am able to use the regex feature to use subpaths too.

    Example:
    /home:param(.*)
    works in my project (GoRouter 16.2.4) and picks everything after /home and puts it into a String field of my route, even subroutes.
    (This obviously disables the ability of GoRouter to detect manually defined subroutes for that route, as everything matches the regex)
    EDIT: i just setup a minimal example project and it seems that this does only work with go_router_builder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions