Skip to content

[go_router] Expose Navigator clipBehavior on ShellRoute and StatefulShellBranch - #12646

Open
m1roxx wants to merge 1 commit into
flutter:mainfrom
m1roxx:go-router-shell-clip-behavior
Open

[go_router] Expose Navigator clipBehavior on ShellRoute and StatefulShellBranch#12646
m1roxx wants to merge 1 commit into
flutter:mainfrom
m1roxx:go-router-shell-clip-behavior

Conversation

@m1roxx

@m1roxx m1roxx commented Aug 27, 2026

Copy link
Copy Markdown

The Navigator that ShellRoute and each StatefulShellBranch build always clipped its contents, with no way to opt out. A sub-route could therefore not paint outside the bounds the shell lays out for it — a box shadow or an overflowing menu gets cut off (see the samples in the issue).

This adds a clipBehavior parameter to ShellRoute and StatefulShellBranch that is forwarded to the Navigator each of them builds, as suggested by @chunhtai in flutter/flutter#131836 (comment).

It defaults to Clip.hardEdge, which is Navigator's own default, so existing behavior is unchanged. As noted in the issue discussion, setting Clip.none also lets route transition animations paint outside the shell's bounds; that trade-off is documented on the new clipBehavior doc comment so callers can make an informed choice.

StatefulShellBranch carries the parameter rather than StatefulShellRoute because each branch builds its own Navigator, which is how observers and restorationScopeId are already configured.

Fixes flutter/flutter#131836

Pre-Review Checklist

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

…hellBranch

Nested shell Navigators always clipped their contents, so a sub-route
could not paint outside the bounds the shell laid out for it (a box
shadow or an overflowing menu got cut off).

Adds a `clipBehavior` parameter to `ShellRoute` and `StatefulShellBranch`
that is forwarded to the `Navigator` each of them builds. It defaults to
`Clip.hardEdge`, which is the `Navigator` default, so existing behavior
is unchanged.

Branches configure this individually because each `StatefulShellBranch`
builds its own `Navigator`, matching how `observers` and
`restorationScopeId` already work.
@google-cla

google-cla Bot commented Aug 27, 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.

@github-actions github-actions Bot added p: go_router triage-framework Should be looked at in framework triage labels Aug 27, 2026

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

Copy link
Copy Markdown
Contributor

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 adds a clipBehavior property to ShellRoute and StatefulShellBranch in go_router, which is forwarded to the nested Navigator to control whether sub-routes can paint outside the shell's bounds. The feedback suggests specifying the default value Clip.hardEdge directly in the NavigatorBuilder typedef to ensure that custom or mock implementations can statically resolve the default value correctly.

Comment on lines +59 to +61
String? restorationScopeId, {
Clip clipBehavior,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

In the NavigatorBuilder typedef, the newly added optional named parameter clipBehavior is non-nullable but does not have a default value specified. Although the implementation in builder.dart provides a default value, it is highly recommended to specify the default value Clip.hardEdge directly in the typedef as well. This ensures that any caller of NavigatorBuilder (such as custom or mock implementations in tests) can statically resolve the default value correctly without relying on the implementation details.

Suggested change
String? restorationScopeId, {
Clip clipBehavior,
});
String? restorationScopeId, {
Clip clipBehavior = Clip.hardEdge,
});

@m1roxx

m1roxx commented Aug 27, 2026

Copy link
Copy Markdown
Author

@googlebot I signed it!

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] Expose Navigator.clipBehavior to ShellRoute

1 participant