Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment thread
lamek marked this conversation as resolved.
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
Loading