-
Notifications
You must be signed in to change notification settings - Fork 3.5k
docs: update predictive back guide to reflect default behavior #13675
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
Open
lamek
wants to merge
1
commit into
main
Choose a base branch
from
fix-12201
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−44
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
76 changes: 32 additions & 44 deletions
76
sites/docs/src/content/platform-integration/android/predictive-back.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,61 +1,49 @@ | ||
| --- | ||
| title: Add the predictive-back gesture | ||
| shortTitle: Predictive-back | ||
| title: Add the predictive back gesture | ||
| shortTitle: Predictive back | ||
| description: >- | ||
| Learn how to add the predictive back gesture to your Android app. | ||
| Learn how to support the predictive back gesture in your Android app. | ||
| --- | ||
|
|
||
| This feature has landed in Flutter, | ||
| but it's not enabled by default in Android itself yet. | ||
| You can try it out using the following instructions. | ||
| Flutter supports the predictive back gesture on Android by default. | ||
| However, to opt in to the platform feature, | ||
| you must configure your Android app. | ||
|
|
||
| ## Configure your app | ||
|
|
||
| Make sure your app supports Android API 33 or higher, | ||
| as predictive back won't work on older versions of Android. | ||
| Then, set the flag `android:enableOnBackInvokedCallback="true"` | ||
| in `android/app/src/main/AndroidManifest.xml`. | ||
| To support the predictive back gesture, | ||
| your app must target Android API level 33 (Android 13) or higher. | ||
|
|
||
| ## Configure your device | ||
| To opt in, add the `android:enableOnBackInvokedCallback="true"` attribute | ||
| to the `<application>` tag | ||
| in your `android/app/src/main/AndroidManifest.xml` file: | ||
|
|
||
| You need to enable Developer Mode and set a flag on your device, | ||
| so you can't yet expect predictive back to work on most users' | ||
| Android devices. If you want to try it out on your own device though, | ||
| make sure it's running API 33 or higher, and then in | ||
| **Settings => System => Developer** options, | ||
| make sure the switch is enabled next to **Predictive back animations**. | ||
|
|
||
| ## Set up your app | ||
|
|
||
| The predictive back route transitions are currently | ||
| not enabled by default, so for now you'll need to enable them | ||
| manually in your app. | ||
| Typically, you do this by setting them in your theme: | ||
|
|
||
| ```dart | ||
| MaterialApp( | ||
| theme: ThemeData( | ||
| pageTransitionsTheme: const PageTransitionsTheme( | ||
| builders: <TargetPlatform, PageTransitionsBuilder>{ | ||
| // Set the predictive back transitions for Android. | ||
| TargetPlatform.android: PredictiveBackPageTransitionsBuilder(), | ||
| }, | ||
| ), | ||
| ), | ||
| ... | ||
| ), | ||
| ```xml | ||
| <application | ||
| ... | ||
| android:enableOnBackInvokedCallback="true"> | ||
| </application> | ||
| ``` | ||
|
|
||
| ## Run your app | ||
| ## Configure your device | ||
|
|
||
| Lastly, just make sure you're using at least | ||
| Flutter version 3.22.2 to run your app, | ||
| which is the latest stable release at the time of this writing. | ||
| Depending on the Android version of your test device, | ||
| you might need to enable the gesture in the system settings: | ||
|
|
||
| * **Android 13 (API level 33):** | ||
| Enable **Predictive back animations** under | ||
| **Settings** > **System** > **Developer options**. | ||
| * **Android 14 (API level 34) and higher:** | ||
| The gesture and its animations are enabled by default. | ||
|
|
||
| ## Run your app | ||
|
|
||
| ## For more information | ||
| To run your app with predictive back support, | ||
| use Flutter 3.38 or higher. | ||
|
|
||
| You can find more information at the following link: | ||
| ## See also | ||
|
|
||
| * [Android predictive back][] breaking change | ||
| For details, | ||
| see [Android predictive back][]. | ||
|
|
||
| [Android predictive back]: /release/breaking-changes/android-predictive-back | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.