Skip to content

Conversation

@justinmc
Copy link
Contributor

In the transition to PopScope, WillPopScope.onWillPop was broken when used on a root route. This PR fixes it by disabling predictive back whenever a WillPopScope is in the widget tree. It's not possible for WillPopScope to work with predictive back, so I think it's fair to disable it. Better to turn off predictive back than to quietly break WillPopScope.

Anyone that wants predictive back support should migrate to PopScope.

Fixes #151432

@justinmc justinmc self-assigned this Jul 19, 2024
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: routes Navigator, Router, and related APIs. labels Jul 19, 2024
@justinmc justinmc marked this pull request as draft July 19, 2024 22:51
@justinmc justinmc requested a review from chunhtai July 19, 2024 23:25
@justinmc justinmc marked this pull request as ready for review July 19, 2024 23:25
Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

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

Can you please add to the documentation here https://docs.flutter.dev/release/breaking-changes/android-predictive-back
To let users know that widgets can impact if predictive back is enabled? This pr feels like an improvement but one that would be confusing to debug if you were getting unexpected behavior.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@justinmc justinmc merged commit bb8f6b0 into flutter:master Jul 22, 2024
@justinmc justinmc deleted the will-pop-scope-on-initial-route branch July 22, 2024 17:06
@justinmc
Copy link
Contributor Author

Website update PR: flutter/website#10928

@justinmc
Copy link
Contributor Author

And we should probably mention this here too: #152116 @reidbaker

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 22, 2024
sfshaza2 added a commit to flutter/website that referenced this pull request Jul 22, 2024
Make it clear that using WillPopScope does not support predictive back.
In
flutter/flutter#152057 (review)
it was mentioned that this should be explicitly communicated in this
breaking changes page.

_Issues fixed by this PR (if any):_ n/a

_PRs or commits this PR depends on (if any):_
flutter/flutter#152057

## Presubmit checklist

- [x] This PR is marked as draft with an explanation if not meant to
land until a future stable release.
- [x] This PR doesn’t contain automatically generated corrections
(Grammarly or similar).
- [x] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style) — for example, it
doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person).
- [x] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
of 80 characters or fewer.

---------

Co-authored-by: Shams Zakhour (ignore Sfshaza) <[email protected]>
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 23, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 24, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 24, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 24, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 24, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 24, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 25, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 26, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 28, 2024
auto-submit bot pushed a commit that referenced this pull request Aug 1, 2024
Clearly explains that WillPopScope will break predictive back support.

Came up in #152057 (review).
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
Fixes a bug where WillPopScope no longer worked on the home route.

With this PR, Android's predictive back feature will be explicitly disabled when a WillPopScope widget is in the widget tree. To get the same behavior and still support predictive back, use PopScope.
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
…152116)

Clearly explains that WillPopScope will break predictive back support.

Came up in flutter#152057 (review).
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
Fixes a bug where WillPopScope no longer worked on the home route.

With this PR, Android's predictive back feature will be explicitly disabled when a WillPopScope widget is in the widget tree. To get the same behavior and still support predictive back, use PopScope.
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…152116)

Clearly explains that WillPopScope will break predictive back support.

Came up in flutter#152057 (review).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WillPopScope.onWillPop not called on home route when using FlutterFragment

3 participants