Skip to content

[go_router] Add route metadata support to GoRouterState.#11773

Open
star4277 wants to merge 2 commits into
flutter:mainfrom
star4277:main
Open

[go_router] Add route metadata support to GoRouterState.#11773
star4277 wants to merge 2 commits into
flutter:mainfrom
star4277:main

Conversation

@star4277
Copy link
Copy Markdown

@star4277 star4277 commented May 25, 2026

This PR adds route metadata support across go_router route definitions, match resolution, and GoRouterState, including inheritance/override behavior and test coverage.

  • Added metadata support to RouteBase and all relevant route types.
  • Propagated merged route metadata into GoRouterState.
  • Added metadata resolution/merge logic in route matching:
  • inherit from parents
  • child keys override parent keys
  • default to empty map when absent
  • Wired top-level/error state builders to include metadata.
  • Added regression test coverage for metadata inheritance/override/empty behavior.

Fixes flutter/flutter#187049, flutter/flutter#160738.

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

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 25, 2026

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.

@github-actions github-actions Bot added p: go_router triage-framework Should be looked at in framework triage labels May 25, 2026
Copy link
Copy Markdown

@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 a metadata property to RouteBase and GoRouterState, enabling the association of custom data with routes. The implementation includes logic within RouteMatchList to handle metadata inheritance and overriding during route matching. GoRouterState is updated to incorporate this metadata into its equality and hashing logic, and new tests verify the expected behavior. I have no feedback to provide.

@stuartmorgan-g stuartmorgan-g requested a review from chunhtai May 26, 2026 18:25
@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

[x] I followed the version and CHANGELOG instructions, using semantic versioning and the repository CHANGELOG style, or I have commented below to indicate which documented exception this PR falls under1.

@star4277 I don't see this reflected in the PR. Are there changes you forgot to push?

@star4277
Copy link
Copy Markdown
Author

[x] I followed the version and CHANGELOG instructions, using semantic versioning and the repository CHANGELOG style, or I have commented below to indicate which documented exception this PR falls under1.

@star4277 I don't see this reflected in the PR. Are there changes you forgot to push?

Sorry, I missed it, I've made it up now

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

Labels

p: go_router triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go_router] Support route metadata inheritance and exposure via GoRouterState

2 participants