Skip to content
Merged
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
53 changes: 52 additions & 1 deletion src/release/breaking-changes/android-predictive-back.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,60 @@ if (_route.popDisposition == RoutePopDisposition.doNotPop) {
}
```

### Migrating a back confirmation dialog

`WillPopScope` was sometimes used to show a confirmation dialog when
a back gesture was received.
This can still be done with `PopScope` in a similar pattern.

Code before migration:

```dart
WillPopScope(
onWillPop: () async {
final bool? shouldPop = await _showBackDialog();
return shouldPop ?? false;
},
child: child,
)
```

Code after migration:

```dart
return PopScope(
canPop: false,
onPopInvoked: (bool didPop) async {
if (didPop) {
return;
}
final NavigatorState navigator = Navigator.of(context);
final bool? shouldPop = await _showBackDialog();
if (shouldPop ?? false) {
navigator.pop();
}
},
child: child,
)
```

### Supporting predictive back

1. Run Android 33 or above.
1. Enable the feature flag for predictive back on
the device under "Developer options".
This will be unnecessary on future versions of Android.
1. Set `android:enableOnBackInvokedCallback="true"` in
`android/app/src/main/AndroidManifest.xml`. If needed, refer to
[Android's full guide](https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture)
for migrating Android apps to support predictive back.
1. Make sure you're using version `3.14.0-7.0.pre` of Flutter or greater.
1. Run the app and perform a back gesture (swipe from the left side of
the screen).

## Timeline

Landed in version: 3.14.0-0.0.pre<br>
Landed in version: 3.14.0-7.0.pre<br>
In stable release: not yet

## References
Expand Down