Examples of Android's predictive back feature in Flutter

Predictive back examples

Various examples of Android’s predictive back feature.

Currently only works when popping out of the Flutter app, not between routes inside the Flutter app.

Getting predictive back to work in Flutter

  1. Run Android 33 or above.
  2. Enable the feature flag for predictive back on the device under “Developer options”.
  3. Create a Flutter project, or clone this one.
  4. Set android:enableOnBackInvokedCallback="true" in android/app/src/main/AndroidManifest.xml (already done in this project).
  5. Make sure your version of Flutter contains PR 120385. If it’s not yet merged, you’ll need to check out that branch specifically. After it is merged, compare the version it’s in to your Flutter version, or use the latest master.
  6. Run the app. Perform a back gesture (swipe from the left side of the screen).

You should see the predictive back animation and be able to commit or cancel it.

Resources

GitHub

View Github