Skip to content

[go_router]: Add RelativeGoRouteData and TypedRelativeGoRoute #9732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

LukasMirbt
Copy link
Contributor

@LukasMirbt LukasMirbt commented Aug 3, 2025

Adds RelativeGoRouteData and TypedRelativeGoRoute to support type-safe relative routes.

Foundation for #9749 which adds relative route support in go_router_builder.

Continuation of #8476 by @ThangVuNguyenViet

Compared to #8476, the approach taken in this PR avoids breaking changes and creates a separate RouteData subclass instead of extending GoRouteData. The approach increases flexibility and avoids extending behavior that might not make sense for a relative route.

Necessary to fully resolve flutter/flutter#108177.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@LukasMirbt LukasMirbt requested a review from chunhtai as a code owner August 3, 2025 13:27
Copy link

google-cla bot commented Aug 3, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces type-safe relative routes by adding RelativeGoRouteData and TypedRelativeGoRoute. The changes are well-tested. My main feedback concerns significant code duplication in the new RelativeGoRouteData class, which poses a maintainability risk. I've also pointed out a minor bug and some areas for improvement in the new tests.

@LukasMirbt LukasMirbt force-pushed the go-router/add-relative-go-route-data branch from f778d2e to e8c8f2b Compare August 4, 2025 21:56
@bbhawal-atec
Copy link

I am curious how this would work with deeplinking, or whether it would even be possible to support it

@LukasMirbt
Copy link
Contributor Author

I am curious how this would work with deeplinking, or whether it would even be possible to support it

Deep-linking should be fully supported!

If you have a use case you want to test before this PR is merged, add the following to your pubspec.yaml:

dependencies:
  go_router:
    git:
      url: https://github.com/LukasMirbt/packages.git
      ref: relative-routes
      path: packages/go_router

dev_dependencies:
  go_router_builder:
    git:
      url: https://github.com/LukasMirbt/packages.git
      ref: relative-routes
      path: packages/go_router_builder

@LukasMirbt LukasMirbt force-pushed the go-router/add-relative-go-route-data branch 13 times, most recently from 8224a3c to 2777140 Compare August 11, 2025 14:34
@LukasMirbt LukasMirbt force-pushed the go-router/add-relative-go-route-data branch 11 times, most recently from c69f5a8 to 1dcb3ec Compare August 18, 2025 19:49
Copy link
Member

@hannah-hyj hannah-hyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LukasMirbt LukasMirbt force-pushed the go-router/add-relative-go-route-data branch from 9b3cad8 to 56ddbea Compare August 18, 2025 20:43
@LukasMirbt
Copy link
Contributor Author

@chunhtai Can this PR along with #9749 be auto-submitted or what's the next step?

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 18, 2025
@auto-submit auto-submit bot merged commit 27a2302 into flutter:main Aug 18, 2025
80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 19, 2025
auto-submit bot pushed a commit that referenced this pull request Aug 19, 2025
Adds support for TypedRelativeGoRoute.

Builds on #9732

Continuation of #8476 by @ThangVuNguyenViet

Compared to #8476, the approach taken in this PR avoids breaking changes and creates a separate RouteData subclass instead of extending GoRouteData. The approach increases flexibility and avoids extending behavior that might not make sense for a relative route.

Fully resolves flutter/flutter#108177.

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Aug 19, 2025
flutter/packages@5c52c55...953cae0

2025-08-19 [email protected] Add com.android.tools.build:gradle to
dependabot gradle-plugin group (flutter/packages#9848)
2025-08-19 [email protected] [flutter_migrate] Remove source
(flutter/packages#9847)
2025-08-18 [email protected] [go_router]: Add `RelativeGoRouteData`
and `TypedRelativeGoRoute` (flutter/packages#9732)
2025-08-18 [email protected] Roll Flutter (stable) from
edada7c to 20f8274 (1474 revisions) (flutter/packages#9837)
2025-08-18 [email protected] Roll Flutter from
b3fb4c7 to 2265d94 (7 revisions) (flutter/packages#9845)
2025-08-18 [email protected] Disable SwiftPM for `xcode-analyze`
(flutter/packages#9666)
2025-08-17 [email protected] Roll Flutter from
0a2906b to b3fb4c7 (5 revisions) (flutter/packages#9840)
2025-08-16 [email protected] Update repo for 3.35 stable release
(flutter/packages#9816)
2025-08-16 [email protected] Roll Flutter from
52af7a5 to 0a2906b (16 revisions) (flutter/packages#9836)
2025-08-16 [email protected] [image_picker] Updates min SDK to
3.29 (flutter/packages#9830)
2025-08-16 [email protected] [image_picker] Add the ability to
pick multiple videos (flutter/packages#9775)
2025-08-16 [email protected] [image_picker] Add the ability to
pick multiple videos - platform implementations (flutter/packages#9818)
2025-08-16 [email protected] [various] Updates min SDK for
third_party/packages to 3.29 (flutter/packages#9819)
2025-08-16 [email protected] [vector_graphics] Updates min SDK to
3.29 (flutter/packages#9820)
2025-08-16 [email protected] [google_maps_flutter] Updates min SDK
to 3.29 (flutter/packages#9821)
2025-08-16 [email protected] [video_player] Updates min SDK to
3.29 (flutter/packages#9826)
2025-08-15 [email protected] [shared_preferences] Updates min SDK
to 3.29 (flutter/packages#9829)
2025-08-15 [email protected] [image_picker_ios] Add photo to simulator
Photos library during test (flutter/packages#9759)
2025-08-15 [email protected]
[interactive_media_ads] Updates `README` with information about enabling
desugaring on Android (flutter/packages#9790)
2025-08-15 [email protected] [in_app_purchase] Updates min SDK to
3.29 (flutter/packages#9825)
2025-08-15 [email protected] Roll Flutter from
f4334d2 to 52af7a5 (29 revisions) (flutter/packages#9832)
2025-08-15 [email protected] [go_router] Update generated output
format (flutter/packages#9817)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
WillBLogical pushed a commit to WillBLogical/packages that referenced this pull request Aug 20, 2025
…utter#9732)

Adds `RelativeGoRouteData` and `TypedRelativeGoRoute` to support type-safe relative routes.

Foundation for flutter#9749 which adds relative route support in `go_router_builder`. 

Continuation of flutter#8476 by @ThangVuNguyenViet 

Compared to flutter#8476, the approach taken in this PR avoids breaking changes and creates a separate `RouteData` subclass instead of extending `GoRouteData`. The approach increases flexibility and avoids extending behavior that might not make sense for a relative route.

Necessary to fully resolve flutter/flutter#108177.

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
WillBLogical pushed a commit to WillBLogical/packages that referenced this pull request Aug 20, 2025
Adds support for TypedRelativeGoRoute.

Builds on flutter#9732

Continuation of flutter#8476 by @ThangVuNguyenViet

Compared to flutter#8476, the approach taken in this PR avoids breaking changes and creates a separate RouteData subclass instead of extending GoRouteData. The approach increases flexibility and avoids extending behavior that might not make sense for a relative route.

Fully resolves flutter/flutter#108177.

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: go_router
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[go_router] Add support for relative routes
4 participants