@@ -270,9 +270,60 @@ if (_route.popDisposition == RoutePopDisposition.doNotPop) {
270270}
271271```
272272
273+ ### Migrating a back confirmation dialog
274+
275+ ` WillPopScope ` was sometimes used to show a confirmation dialog when
276+ a back gesture was received.
277+ This can still be done with ` PopScope ` in a similar pattern.
278+
279+ Code before migration:
280+
281+ ``` dart
282+ WillPopScope(
283+ onWillPop: () async {
284+ final bool? shouldPop = await _showBackDialog();
285+ return shouldPop ?? false;
286+ },
287+ child: child,
288+ )
289+ ```
290+
291+ Code after migration:
292+
293+ ``` dart
294+ return PopScope(
295+ canPop: false,
296+ onPopInvoked: (bool didPop) async {
297+ if (didPop) {
298+ return;
299+ }
300+ final NavigatorState navigator = Navigator.of(context);
301+ final bool? shouldPop = await _showBackDialog();
302+ if (shouldPop ?? false) {
303+ navigator.pop();
304+ }
305+ },
306+ child: child,
307+ )
308+ ```
309+
310+ ### Supporting predictive back
311+
312+ 1 . Run Android 33 or above.
313+ 1 . Enable the feature flag for predictive back on
314+ the device under "Developer options".
315+ This will be unnecessary on future versions of Android.
316+ 1 . Set ` android:enableOnBackInvokedCallback="true" ` in
317+ ` android/app/src/main/AndroidManifest.xml ` . If needed, refer to
318+ [ Android's full guide] ( https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture )
319+ for migrating Android apps to support predictive back.
320+ 1 . Make sure you're using version ` 3.14.0-7.0.pre ` of Flutter or greater.
321+ 1 . Run the app and perform a back gesture (swipe from the left side of
322+ the screen).
323+
273324## Timeline
274325
275- Landed in version: 3.14.0-0 .0.pre<br >
326+ Landed in version: 3.14.0-7 .0.pre<br >
276327In stable release: not yet
277328
278329## References
0 commit comments