Skip to content

Conversation

LukasMirbt
Copy link
Contributor

Adds PopScope which prevents iOS back gesture from popping ShellRoute when there are active sub-routes.

Closes flutter/flutter#120353.

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

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 fixes an issue with the iOS back gesture on ShellRoute and StatefulShellRoute. The fix involves wrapping the nested navigator in a PopScope to prevent it from being popped when there are active sub-routes. The logic seems correct and is well-covered by new regression tests for both ShellRoute and StatefulShellRoute.

I have a couple of suggestions for the new test files to improve code clarity and maintainability. Please see my comments.

@LukasMirbt LukasMirbt force-pushed the go-router/shell-route-ios-back-gesture branch 2 times, most recently from 4f660f0 to 357db32 Compare September 7, 2025 12:12
@LukasMirbt LukasMirbt force-pushed the go-router/shell-route-ios-back-gesture branch from 986413c to 1a2594d Compare September 7, 2025 19:42
errorBuilder: widget.errorBuilder,
errorPageBuilder: widget.errorPageBuilder,
requestFocus: widget.requestFocus,
return PopScope(
Copy link
Contributor

Choose a reason for hiding this comment

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

@justinmc is this the right way to prevent an iOS backgesture? or should we use NavigatorPopHandler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like Justin is on vacation. Is there anybody else we can loop in or should we wait for him?

Screenshot 2025-09-09 at 19 38 54

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wait for him. I "think" we should use NavigatorPopHandler and I also remember Justin was also fixing something about the nested navigator in go_router

@chunhtai chunhtai requested a review from justinmc September 8, 2025 18:50
@wengxianxun
Copy link

16.x is shit

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] ShellRoutes break iOS swipe back navigation
3 participants