Repository navigation
Commit 3c7764b
authored
[go_router] Stop inactive StatefulShellRoute branches from vetoing pops (#12972)
The Navigator of every StatefulShellRoute branch is wrapped in a PopScope that
keeps the shell itself from being popped, for example by an iOS back gesture,
while the branch has an active sub-route.
Inactive branches stay mounted, so their PopScope stays registered as a pop
entry of the same enclosing route as the active one, and ModalRoute only allows
a pop if every registered entry allows it. Switching away from a branch that
still had a sub-route therefore suppressed the system back button for the whole
app: popRoute() reported the pop as handled without popping anything, so Android
never closed the activity.
The guard now only applies to the active branch. StatefulNavigationShell
publishes which of its branches is active through an ActiveBranchScope inherited
widget, and the PopScope depends on it, so canPop is also kept up to date when
the user switches branches without the route matches of a branch changing.
Behavior is unchanged for a plain ShellRoute, which has no enclosing
ActiveBranchScope.
Tests added to `test/stateful_shell_route_system_back_test.dart`, next to the
existing issue 120353 gesture tests: the issue's repro, back still popping the
sub-route once the branch is active again, and a per-branch `canPop` check
confirming the active branch still guards the shell. Also verified manually on
an Android 15 device.
Fixes flutter/flutter#193098
*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*
*List which issues are fixed by this PR. You must list at least one issue.*
## Pre-Review Checklist
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). 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.
[^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.1 parent 10edd9c commit 3c7764b
5 files changed
Lines changed: 345 additions & 28 deletions
File tree
- packages/go_router
- lib/src
- misc
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
363 | 379 | | |
364 | 380 | | |
365 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
1635 | 1636 | | |
1636 | 1637 | | |
1637 | 1638 | | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
1638 | 1642 | | |
1639 | | - | |
1640 | | - | |
| 1643 | + | |
| 1644 | + | |
1641 | 1645 | | |
1642 | 1646 | | |
1643 | 1647 | | |
1644 | 1648 | | |
| 1649 | + | |
1645 | 1650 | | |
1646 | 1651 | | |
1647 | 1652 | | |
| |||
1712 | 1717 | | |
1713 | 1718 | | |
1714 | 1719 | | |
1715 | | - | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
1716 | 1726 | | |
1717 | 1727 | | |
1718 | 1728 | | |
1719 | 1729 | | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
1720 | 1733 | | |
1721 | 1734 | | |
1722 | 1735 | | |
| |||
1729 | 1742 | | |
1730 | 1743 | | |
1731 | 1744 | | |
1732 | | - | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
1733 | 1749 | | |
1734 | 1750 | | |
1735 | 1751 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments