| [ Web Proxy ] |
| Viewing: https://docs.flutter.dev/platform-integration/android/predictive-back | [Back] [Original] |
docs.flutter.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.
Learn how to enable and handle Android predictive back gestures in Flutter.
The Android predictive back gesture lets users preview where a back gesture will navigate to, whether that's the previous screen or the home screen, before they commit to or cancel it.
Starting with Android 14 (API level 34), predictive back animations are enabled by default for system gestures when supported by the application. Flutter provides built-in support for predictive back animations across default page route transitions and custom pop handling.
To support predictive back gestures in your Flutter app on Android 13 or later:
android/app/src/main/AndroidManifest.xml.android:enableOnBackInvokedCallback="true" to the <application> tag:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="my_app"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:enableOnBackInvokedCallback="true">
<!-- ... -->
</application>
</manifest>
To customize back navigation or prevent users
from accidentally leaving a screen,
use the PopScope
widget.
PopScope replaces the deprecated WillPopScope widget
and supports predictive back gestures.
PopScope uses the onPopInvokedWithResult callback:
didPop: A boolean indicating whether the pop operation succeeded.
If canPop is false, didPop is false.
result: An optional return payload passed when popping the route
(for example, with Navigator.pop(context, result)).
PopScope(
canPop: false,
onPopInvokedWithResult: (bool didPop, Object? result) async {
if (didPop) {
return;
}
final shouldLeave = await _showExitConfirmationDialog(context);
if (shouldLeave && context.mounted) {
Navigator.of(context).pop(result);
}
},
child: Scaffold(
appBar: AppBar(title: const Text('Form Screen')),
body: const Center(child: Text('Complete the form before leaving.')),
),
)
For more details on API migrations, see the Android predictive back migration guide.
Unless stated otherwise, the documentation on this site reflects Flutter 3.44.7. Page last updated on 2026-08-18. View source or report an issue.
| Web Proxy Viewer | New URL | Original Page |