-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Predictive back support for root routes #120385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… stack has multiple routes
…nfra and replacing it with ahead-of-time
2e3afaa to
998a251
Compare
7939a36 to
a391efa
Compare
flutter/flutter@2ba9f7b...ad0aa8d 2023-08-07 [email protected] Roll Flutter Engine from b10891e0d8d8 to 5b47c0577060 (1 revision) (flutter/flutter#132040) 2023-08-07 [email protected] Roll Flutter Engine from 4304d6180264 to b10891e0d8d8 (1 revision) (flutter/flutter#132037) 2023-08-07 [email protected] Roll Flutter Engine from eb91441398a1 to 4304d6180264 (1 revision) (flutter/flutter#132031) 2023-08-07 [email protected] Constrain _RenderScaledInlineWidget child size in computeDryLayout (flutter/flutter#131765) 2023-08-07 [email protected] Roll Flutter Engine from 15b5707af406 to eb91441398a1 (1 revision) (flutter/flutter#132025) 2023-08-07 [email protected] Roll Flutter Engine from a1d513f78bbb to 15b5707af406 (2 revisions) (flutter/flutter#132020) 2023-08-06 [email protected] Roll Flutter Engine from c9bd380ccbb0 to a1d513f78bbb (1 revision) (flutter/flutter#132015) 2023-08-06 [email protected] Roll Flutter Engine from 060c95f94364 to c9bd380ccbb0 (1 revision) (flutter/flutter#132008) 2023-08-06 [email protected] Roll Flutter Engine from af7aaae2f1f9 to 060c95f94364 (1 revision) (flutter/flutter#132006) 2023-08-06 [email protected] Roll Flutter Engine from cdafc05a7217 to af7aaae2f1f9 (2 revisions) (flutter/flutter#132004) 2023-08-05 [email protected] Roll Flutter Engine from b512df490c94 to cdafc05a7217 (1 revision) (flutter/flutter#131996) 2023-08-05 [email protected] Take paint offset into account for inline children hit test in Editable (flutter/flutter#131675) 2023-08-05 [email protected] Roll Flutter Engine from d26b8c8fb60c to b512df490c94 (1 revision) (flutter/flutter#131987) 2023-08-05 [email protected] Roll Flutter Engine from 2ce2913acbe4 to d26b8c8fb60c (1 revision) (flutter/flutter#131986) 2023-08-05 [email protected] Roll Flutter Engine from 628b086265f2 to 2ce2913acbe4 (1 revision) (flutter/flutter#131983) 2023-08-05 [email protected] Roll Flutter Engine from 7302a678e58e to 628b086265f2 (1 revision) (flutter/flutter#131976) 2023-08-05 [email protected] Roll Flutter Engine from 138a1ea9a692 to 7302a678e58e (2 revisions) (flutter/flutter#131975) 2023-08-05 [email protected] Roll Flutter Engine from a0d650e37f5d to 138a1ea9a692 (2 revisions) (flutter/flutter#131972) 2023-08-05 [email protected] Add TODO to refactor error handling. (flutter/flutter#131878) 2023-08-05 [email protected] Manual roll Flutter Engine from 4f4734cd48da to a0d650e37f5d (3 revisions) (flutter/flutter#131967) 2023-08-05 [email protected] Mark the ci_yaml roller task so that it is not backfilled. (flutter/flutter#131966) 2023-08-05 [email protected] mark linux packages_autoroller flaky because of token issue (flutter/flutter#131970) 2023-08-04 [email protected] Sped up the time to find macrobenchmarks. (flutter/flutter#131959) 2023-08-04 [email protected] Roll Flutter Engine from c254deb8fbda to 4f4734cd48da (2 revisions) (flutter/flutter#131955) 2023-08-04 [email protected] Roll Flutter Engine from a7bea8621f4b to c254deb8fbda (3 revisions) (flutter/flutter#131950) 2023-08-04 [email protected] Predictive back support for root routes (flutter/flutter#120385) 2023-08-04 [email protected] Roll Flutter Engine from e9f80bff0703 to a7bea8621f4b (3 revisions) (flutter/flutter#131948) 2023-08-04 [email protected] Roll Flutter Engine from badca1f7f8c9 to e9f80bff0703 (6 revisions) (flutter/flutter#131943) 2023-08-04 [email protected] Mention `showTimePicker` function be can be used to show dialog with the time picker in the `TimePickerDialog` docs (flutter/flutter#131932) 2023-08-04 [email protected] Check for simulator runtime in flutter doctor (flutter/flutter#131795) 2023-08-04 [email protected] Roll Packages from d00c1f9 to ce53da1 (3 revisions) (flutter/flutter#131935) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Breaking google testing revert of: #120385 b/295065534 *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat Co-authored-by: Jesús S Guerrero <[email protected]>
Breaking google testing revert of: flutter#120385 b/295065534
## Description This PR upgrades to Flutter v3.16.3. We faced the following breaking changes: * [Deprecated just-in-time navigation pop APIs for Android Predictive Back](https://docs.flutter.dev/release/breaking-changes/android-predictive-back) * [The ThemeData.useMaterial3 property is now set to true by default](https://docs.flutter.dev/release/breaking-changes/material-3-default) ## Material 3 For now, we just opt out of Material 3 because it requires some more manual migration and isn't our current focus (#1159). ## Predictive Back > Android 14 introduced the [Predictive Back feature](https://developer.android.com/guide/navigation/predictive-back-gesture), which allows the user to peek behind the current route during a valid back gesture and decide whether to continue back or to cancel the gesture. This was incompatible with Flutter’s navigation APIs that allow the developer to cancel a back gesture after it is received. > > With predictive back, the back animation begins immediately when the user initiates the gesture and before it has been committed. There is no opportunity for the Flutter app to decide whether it’s allowed to happen at that time. It must be known ahead of time. > > For this reason, all APIs that allow a Flutter app developer to cancel a back navigation at the time that a back gesture is received are now deprecated. They have been replaced with equivalent APIs that maintain a boolean state at all times that dictates whether or not back navigation is possible. When it is, the predictive back animation happens as usual. Otherwise, navigation is stopped. In both cases, the app developer is informed that a back was attempted and whether it was successful. From https://docs.flutter.dev/release/breaking-changes/android-predictive-back#background We mostly have used `WillPopScope` for confirmation dialogs, so the migration looked like this: ```dart WillPopScope( onWillPop: () async { final bool? shouldPop = await _showBackDialog(); return shouldPop ?? false; }, child: child, ) ``` to ```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, ) ``` https://docs.flutter.dev/release/breaking-changes/android-predictive-back#migrating-a-back-confirmation-dialog ### Run the application with predictive back 1. Run Android 33 or above. 2. Enable the feature flag for predictive back on the device under “Developer options”. This will be unnecessary on future versions of Android. 3. 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. 4. Make sure you’re using version 3.14.0-7.0.pre of Flutter or greater. 5. Run the app and perform a back gesture (swipe from the left side of the screen). https://docs.flutter.dev/release/breaking-changes/android-predictive-back#supporting-predictive-back Unfortunately, I wasn't able to get predictive back animations running in a Flutter app. They work for me in the native settings app, but not in a Flutter app (even with the example app). I think it shouldn't be that a big deal because it should work that way as we have it. Here is a demo of how it should look: flutter/flutter#120385. ## Testing I tested the changes manually. --------- Co-authored-by: Jonas Sander <[email protected]>
## Description This PR upgrades to Flutter v3.16.3. We faced the following breaking changes: * [Deprecated just-in-time navigation pop APIs for Android Predictive Back](https://docs.flutter.dev/release/breaking-changes/android-predictive-back) * [The ThemeData.useMaterial3 property is now set to true by default](https://docs.flutter.dev/release/breaking-changes/material-3-default) ## Material 3 For now, we just opt out of Material 3 because it requires some more manual migration and isn't our current focus (#1159). ## Predictive Back > Android 14 introduced the [Predictive Back feature](https://developer.android.com/guide/navigation/predictive-back-gesture), which allows the user to peek behind the current route during a valid back gesture and decide whether to continue back or to cancel the gesture. This was incompatible with Flutter’s navigation APIs that allow the developer to cancel a back gesture after it is received. > > With predictive back, the back animation begins immediately when the user initiates the gesture and before it has been committed. There is no opportunity for the Flutter app to decide whether it’s allowed to happen at that time. It must be known ahead of time. > > For this reason, all APIs that allow a Flutter app developer to cancel a back navigation at the time that a back gesture is received are now deprecated. They have been replaced with equivalent APIs that maintain a boolean state at all times that dictates whether or not back navigation is possible. When it is, the predictive back animation happens as usual. Otherwise, navigation is stopped. In both cases, the app developer is informed that a back was attempted and whether it was successful. From https://docs.flutter.dev/release/breaking-changes/android-predictive-back#background We mostly have used `WillPopScope` for confirmation dialogs, so the migration looked like this: ```dart WillPopScope( onWillPop: () async { final bool? shouldPop = await _showBackDialog(); return shouldPop ?? false; }, child: child, ) ``` to ```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, ) ``` https://docs.flutter.dev/release/breaking-changes/android-predictive-back#migrating-a-back-confirmation-dialog ### Run the application with predictive back 1. Run Android 33 or above. 2. Enable the feature flag for predictive back on the device under “Developer options”. This will be unnecessary on future versions of Android. 3. 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. 4. Make sure you’re using version 3.14.0-7.0.pre of Flutter or greater. 5. Run the app and perform a back gesture (swipe from the left side of the screen). https://docs.flutter.dev/release/breaking-changes/android-predictive-back#supporting-predictive-back Unfortunately, I wasn't able to get predictive back animations running in a Flutter app. They work for me in the native settings app, but not in a Flutter app (even with the example app). I think it shouldn't be that a big deal because it should work that way as we have it. Here is a demo of how it should look: flutter/flutter#120385. ## Testing I tested the changes manually. --------- Co-authored-by: Jonas Sander <[email protected]>
|
This may've caused issues in new flutter app supposed to run on android 7. Issues are as below 2024-02-13 13:28:31.588 7001-7001 art pid-7001 I Rejecting re-init on previously-failed class java.lang.Class<io.flutter.embedding.android.f$a>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/window/OnBackInvokedCallback; |
|
@parthpatel-simbiotik Can you file a new issue for that? |
This PR aims to support Android's predictive back gesture when popping the entire Flutter app. Predictive route transitions between routes inside of a Flutter app will come later.
Trying it out
If you want to try this feature yourself, here are the necessary steps:
options".
android:enableOnBackInvokedCallback="true"inandroid/app/src/main/AndroidManifest.xml (already done in the example project).
screen).
You should see the predictive back animation like in the animation above and be able to commit or cancel it.
go_router support
go_router works with predictive back out of the box because it uses a Navigator internally that dispatches NavigationNotifications!
go_router can be supported by adding a listener to the router and updating SystemNavigator.setFrameworkHandlesBack.Similar to with nested Navigators, nested go_routers is supported by using a PopScope widget.
Full example of nested go_routers
Resources
Fixes #109513
Depends on engine PR flutter/engine#39208 ✔️
Design doc: https://docs.google.com/document/d/1BGCWy1_LRrXEB6qeqTAKlk-U2CZlKJ5xI97g45U7azk/edit#
Migration guide: flutter/website#8952