-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Migration guide for predictive back #8952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
0aafccc
5f19de4
e90c97c
ec56e96
a8aa178
bc2f56e
f16aeb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,314 @@ | ||||||||||||||||||||
| --- | ||||||||||||||||||||
| title: Android Predictive Back | ||||||||||||||||||||
| description: > | ||||||||||||||||||||
| The ability to control back navigation at the time that a back gesture is | ||||||||||||||||||||
| received has been replaced with an ahead-of-time navigation API in order to | ||||||||||||||||||||
| support Android 14's Predictive Back feature. | ||||||||||||||||||||
| --- | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Summary | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Flutter's just-in-time navigation APIs, like `WillPopScope` and | ||||||||||||||||||||
| `Navigator.willPop`, are being replaced with a set of ahead-of-time APIs in | ||||||||||||||||||||
| order to support Android 14's Predictive Back feature. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Background | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Android 14 introduced the | ||||||||||||||||||||
| [Predictive Back feature](https://developer.android.com/guide/navigation/predictive-back-gesture), | ||||||||||||||||||||
| which allows the user to peek behind the current route during a valid back | ||||||||||||||||||||
| gesture and decide whether or not to continue back or to cancel the gesture. | ||||||||||||||||||||
|
||||||||||||||||||||
| gesture and decide whether or not to continue back or to cancel the gesture. | |
| gesture and decide whether to continue back or to cancel the gesture. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| opportunity for the Flutter app to decide whether or not it is allowed to happen | |
| opportunity for the Flutter app to decide whether it's allowed to happen |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `PopScope` is a direct replacement for `WillPopScope`. Instead of deciding | |
| whether or not a pop is possible at the time it occurs, this is set ahead of | |
| time with the `canPop` boolean. It's also still possible to listen to pops by | |
| using `onPopInvoked`. | |
| The `PopScope` class directly replaces `WillPopScope`. | |
| Instead of deciding whether a pop is possible at the time it occurs, | |
| this is set ahead of time with the `canPop` boolean. | |
| You can still listen to pops by using `onPopInvoked`. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fields? Properties? Methods? It seems like one is a property and the other is a method?
| These replace parameters that corresponded with `WillPopScope` and now are used | |
| with `PopScope` in the same was as above. | |
| These fields replace parameters that corresponded with `WillPopScope` | |
| and are now used with `PopScope` in the same way as above. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| These are used internally to register `PopScope` widgets, so that they are taken | |
| into consideration when the route decides whether or not it can pop. This may be | |
| used if implementing a custom `PopScope` widget. | |
| Use these methods to register `PopScope` widgets, | |
| to be evaluated when the route decides | |
| whether it can pop. This functionality might be | |
| used when implementing a custom `PopScope` widget. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `Form` used to use a `WillPopScope` under the hood and expose its `onWillPop` | |
| method. It has been replaced with a `PopScope` and has exposed its `canPop` and | |
| `onPopInvoked` methods. Migrating is identical to migrating from `WillPopScope` | |
| to `PopScope`, detailed above. | |
| Previously, `Form` used a `WillPopScope` instance under the hood | |
| and exposed its `onWillPop` method. This has been replaced with a | |
| `PopScope` that exposes its `canPop` and `onPopInvoked` methods. | |
| Migrating is identical to migrating from `WillPopScope` | |
| to `PopScope`, detailed above. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `removeScopedWillPopCallback`. Since `WillPopScope` has been replaced by | |
| `PopScope`, these methods have been replaced by `registerPopInterface` and | |
| `removeScopedWillPopCallback`. Since `PopScope` replaces `WillPopScope`, | |
| these methods have been replaced by `registerPopInterface` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.