[go_router] Expose Navigator clipBehavior on ShellRoute and StatefulShellBranch - #12646
[go_router] Expose Navigator clipBehavior on ShellRoute and StatefulShellBranch#12646m1roxx wants to merge 1 commit into
Conversation
…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.
|
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. |
There was a problem hiding this comment.
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.
| String? restorationScopeId, { | ||
| Clip clipBehavior, | ||
| }); |
There was a problem hiding this comment.
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.
| String? restorationScopeId, { | |
| Clip clipBehavior, | |
| }); | |
| String? restorationScopeId, { | |
| Clip clipBehavior = Clip.hardEdge, | |
| }); |
|
@googlebot I signed it! |
The
NavigatorthatShellRouteand eachStatefulShellBranchbuild 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
clipBehaviorparameter toShellRouteandStatefulShellBranchthat is forwarded to theNavigatoreach of them builds, as suggested by @chunhtai in flutter/flutter#131836 (comment).It defaults to
Clip.hardEdge, which isNavigator's own default, so existing behavior is unchanged. As noted in the issue discussion, settingClip.nonealso lets route transition animations paint outside the shell's bounds; that trade-off is documented on the newclipBehaviordoc comment so callers can make an informed choice.StatefulShellBranchcarries the parameter rather thanStatefulShellRoutebecause each branch builds its ownNavigator, which is howobserversandrestorationScopeIdare already configured.Fixes flutter/flutter#131836
Pre-Review Checklist
[shared_preferences]///).Footnotes
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