Skip to content

[go_router_builder] Support conditional redirect-only typed parents - #13122

Draft
kaluli123123 wants to merge 3 commits into
flutter:mainfrom
kaluli123123:fix/192358-typed-redirect-only
Draft

kaluli123123 wants to merge 3 commits into
flutter:mainfrom
kaluli123123:fix/192358-typed-redirect-only

Conversation

@kaluli123123

@kaluli123123 kaluli123123 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

[go_router_builder] Conditional redirects on typed parent routes currently reach the default build/buildPage callbacks and throw UnimplementedError when a descendant should render. This also affects parents of nested stateful shells.

Closes flutter/flutter#192358.

Summary

  • Add an opt-in redirectOnly argument to the generated-code helpers in go_router. It omits builders and the default onExit callback, matching the existing manual GoRoute redirect-only behavior.
  • Generate that argument only for classes that override redirect and inherit both default page methods. Resolve inherited and mixed-in implementations; reject onExit on redirect-only routes, as manual routes already do.
  • Detect whether the resolved core helper supports the new argument. With older go_router, preserve the previous generated output and diagnostics so a builder patch upgrade does not break existing always-redirecting applications.
  • Update documentation and builder version to 4.5.3. Follow the core batch-release policy: retain the upstream 18.1.0 manifest/changelog and queue the additive helper API in a pending minor changelog (planned 18.2.0). Builder development/example dependencies and helper documentation target that future core release.

The earlier discussion in flutter/flutter#103368 predates manual redirect-only support added by #4315. This change brings the typed generator onto that existing behavior rather than changing matching or navigation policy.

Original validation (before the current main sync)

  • Regression first: three public MaterialApp.router cases failed with the reported UnimplementedError before the fix. The final router suite passes, covering root redirects, descendant navigation, relative routes, and two nested stateful shells.
  • Current core: 456 router tests, 17 router example tests, 10 builder tests, 19 builder example tests, and 62 generator/compatibility cases pass (564 total, two existing skips).
  • Older published core: a separate application pins go_router 17.3.0 and uses this local builder. build_runner generates no unsupported redirectOnly argument, fatal analysis passes, and four real widget navigation tests pass for absolute/relative always-redirecting routes with and without onExit.
  • Repository package analysis, validation, Dart formatting, and license checks pass. After committing, the core publish dry run passes with zero warnings. The builder's registry-only dry run cannot resolve the not-yet-published core 18.1.0; maintainers must coordinate the core release before the builder release. A builder dry run using temporary local path overrides passes with zero warnings and one hint about the unpublished intermediate builder version 4.5.1. Overrides were removed and are not committed.
  • Independent read-only runtime review completed. Native device testing and upstream CI have not been established by the local widget tests.

Current refresh validation (2026-10-19)

Synced upstream main 0259ad7e515b74f6855c4c72d81abe2231fe31d3 with a normal merge in 1693cec5afc6e57705ff7cd96eab625b3a3328bb. The changelog conflict is resolved by retaining upstream's released 18.1.0 content and moving the additive helper entry to pending_changelogs/conditional_redirect_only_typed_routes.yaml with version: minor, as required by the current core batch-release validator.

On Flutter 3.47.0, using temporary local path overrides to test the unpublished core helper with the builder:

  • Focused route-data smoke: 32 passed (included in the full core suite).
  • Full core suite: 476 passed; core example: 17 passed; builder suite: 10 passed; builder example: 19 passed; generator/legacy-helper compatibility: 62 passed (584 total across the full suites).
  • Package analysis, committed-tree repository validation, license check, and changed-Dart formatting passed.
  • Both locally linked publish dry runs passed with zero warnings. Overrides were removed and are not committed. Registry-only verification confirms core 18.1.0 is already published, while the builder/example cannot resolve go_router ^18.2.0 because that future core release is not yet published. The pending helper minor must be integrated and released before publishing the builder.

Local passing checks do not establish upstream CI, native-device validation, maintainer approval, or resolution of the historical CLA finding. This PR remains a draft.

Current refresh validation (2026-10-21)

Updated in 60faee2b67 with a normal merge of upstream main 1383427519099a5aae10ca2e1c5c232a6fd88901; no history was rewritten.

  • Resolved the new builder changelog/version collision by retaining upstream's 4.5.2 release and moving this PR's builder release and README reference to 4.5.3. The additive core helper remains a pending minor release (18.2.0); upstream's 18.1.1 manifest/changelog are preserved.
  • Retained the successful post-merge core suite (476 tests) and core example suite (17 tests), run with the default SDK's Dart 3.12.2. The builder now requires Dart 3.13, so its validation used the installed Flutter 3.47.0 / Dart 3.13.0: builder 10, builder example 19, generator/legacy-helper compatibility 62 tests passed. The example suite exercises real build_runner output and verifies it matches the committed generated files.
  • Builder analysis passed. A transient handshake crash in core analysis was followed by a successful direct dart analyze --fatal-infos. Committed-tree repository validation against origin/main, license check, formatting, and both locally linked publish dry runs passed; both packages had zero publish warnings.
  • Temporary local path overrides were removed. Registry-only dependency resolution still fails for both builder and example because go_router ^18.2.0 is not published. The core helper release must precede the builder release; this is not waived by a linked dry run.

This remains a draft pending contributor/maintainer review, the maintainer-controlled CICD label, and required upstream checks. The historical Codex co-author CLA finding is not claimed resolved; normal merges retain that ancestry. Local checks do not establish upstream CI or native-device validation.

Readiness

This contribution was developed with Codex assistance. It remains a draft for contributor and maintainer review; human understanding of the full change has not been asserted. The detailed cla/google output confirms that the submitting author is covered. Its failure is the commit's Codex co-author trailer, which the check treats as an additional uncovered contributor. The historical co-author remains in the original commit, which is retained as an ancestor of the current head. A normal merge cannot remove that contributor from PR history. No history rewrite or force-push was performed, and the historical CLA finding is not claimed resolved. Package CI is also awaiting the maintainer-controlled CICD label. No issue closure, merge, release, or repository configuration change was performed.

Pre-Review Checklist

  • Repository contributor guidance and formatting requirements were consulted.
  • The submitting contributor understands and accepts the AI contribution responsibilities.
  • The submitting author is covered by a CLA, as confirmed by the detailed check; the detected Codex co-author remains the current failure.
  • The title starts with the package name in square brackets.
  • The existing issue is linked above.
  • Versions, changelogs, and relevant documentation are updated.
  • Regression tests are included and the affected local suites pass.
  • Upstream required checks and maintainer review are complete.

Detect redirect-only routes without installing default page builders, and
preserve generated output when the resolved core helper lacks support.

Closes flutter/flutter#192358

Co-authored-by: Codex <noreply@openai.com>
@google-cla

google-cla Bot commented Oct 4, 2026

Copy link
Copy Markdown

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.

Preserve upstream 18.1.0 and use the batch-release pending changelog for the additive helper API planned for 18.2.0. Keep builder documentation and development dependencies aligned with that helper release.
@kaluli123123

Copy link
Copy Markdown
Contributor Author

Updated in 1693cec5af with a normal upstream-main merge; no history was rewritten.

  • Resolved the changelog conflict while preserving upstream 18.1.0. The current repository validator requires batch release for go_router, so the additive helper is now a pending minor changelog (planned 18.2.0), not a direct manifest/changelog bump. Builder helper references target 18.2.0.
  • Flutter 3.47.0: core 476, core example 17, builder 10, builder example 19, generator/legacy-helper compatibility 62 tests passed (584 total). The focused route-data smoke passed 32 tests. Package analysis, committed-tree validation, license check, and changed-Dart formatting passed.
  • Locally linked publish dry runs passed with zero warnings; temporary overrides were removed. The registry-only builder/example check remains blocked because go_router ^18.2.0 is not published. The helper minor release must precede the builder release.
  • The original commit's historical Codex co-author is still in this PR's ancestry. A merge does not remove that CLA contributor; this update does not claim to resolve that historical CLA finding. The submitting author was already covered by the detailed CLA result.

This remains a draft pending contributor/maintainer review, the maintainer-controlled CICD label, and applicable upstream checks. Local tests are not evidence of upstream CI or native-device validation.

@kaluli123123

Copy link
Copy Markdown
Contributor Author

Updated in 60faee2b67 with a normal merge of upstream main 1383427519099a5aae10ca2e1c5c232a6fd88901; no history was rewritten.

  • Resolved the new builder changelog/version collision by retaining upstream's 4.5.2 release and moving this PR's builder release and README reference to 4.5.3. The additive core helper remains a pending minor release (18.2.0); upstream's 18.1.1 manifest/changelog are preserved.
  • Retained the successful post-merge core suite (476 tests) and core example suite (17 tests), run with the default SDK's Dart 3.12.2. The builder now requires Dart 3.13, so its validation used the installed Flutter 3.47.0 / Dart 3.13.0: builder 10, builder example 19, generator/legacy-helper compatibility 62 tests passed. The example suite exercises real build_runner output and verifies it matches the committed generated files.
  • Builder analysis passed. A transient handshake crash in core analysis was followed by a successful direct dart analyze --fatal-infos. Committed-tree repository validation against origin/main, license check, formatting, and both locally linked publish dry runs passed; both packages had zero publish warnings.
  • Temporary local path overrides were removed. Registry-only dependency resolution still fails for both builder and example because go_router ^18.2.0 is not published. The core helper release must precede the builder release; this is not waived by a linked dry run.

This remains a draft pending contributor/maintainer review, the maintainer-controlled CICD label, and required upstream checks. The historical Codex co-author CLA finding is not claimed resolved; normal merges retain that ancestry. Local checks do not establish upstream CI or native-device validation.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go_router_builder] Conditional redirects fail for nested GoRouteData routes with multiple ShellRoute levels

1 participant