r/FlutterDev • u/VMX • Aug 14 '22
Discussion How will Flutter apps adapt to Android 13's predictive back gesture?
For those not aware, Android 13 will implement a cool new animation that will hint users on where they will land if they complete the swipe back gesture.
According to the page I linked, for most native apps it will be enough to just add android:enableOnBackInvokedCallback="true" to the Android Manifest, whereas apps implementing a custom navigation logic will require some more work.
I tried the Android Manifest trick and I can indeed see the new animation (running Android 13 beta on my Pixel 4), but that obviously breaks navigation in my Flutter app completely. Now every back gesture will just take the user back to their homescreen, rather than navigating one level up within Flutter's screen stack (I'm just using the regular navigator push/pop methods).
I've been googling around but I couldn't find anything specific to Flutter, so I'm just wondering: do we know if this is something the Flutter team will implement in the framework without us doing anything? Or will we have to adapt anything ourselves?
If it's the former, I'd expect to have seen something by now given how close we are to Android 13's final release, right?
Does anybody have any info on this? Or maybe I'm missing something obvious and this is a non-issue?
9
u/timsneath Aug 15 '22
Firstly, a huge thanks to /u/VMX for filing the tracking issue: https://github.com/flutter/flutter/issues/109513
Today, our friends over in the Android team started the rollout of Android 13. As noted in their documentation:
Note: Android 13 doesn't make the predictive back gesture visible to users, but it does provide an early version of the UI as a developer option for testing. We plan to make this UI available to users in a future Android release. In the meantime, we strongly recommend updating your app to ensure you get the latest updates.
This is a "multi-year" feature, meaning that it will take time for the overall ecosystem to adapt, not just Flutter (for example, the supporting JetPack library support is also hot off the press. Of course, we want Flutter to offer a highly polished experience on Android, so you can assume that this is under active investigation by our team.
2
u/VMX Aug 15 '22
Thanks to you for stopping by this thread Tim, much appreciated!
First time I file an issue in a big repo like Flutter's, and it looks like I might've accidentally triggered the Android 13 rollout 😅
93
u/ElluxFuror Aug 14 '22
I’m commenting to give this post some action. I have no idea how this will be handled or if it will cause any frustration. However, I think this post is much higher quality than many of the posts I’ve been getting notified.
0
u/cuongmv162 Aug 15 '22
The link OP provided have a miration paths to use new back navigation API, scroll down a bit anf you will see it.
I think with new api and deprecated the old one, tbat would make flutter team time and effort to imolememt it into their framework, how long is q question depened on their manpower.
1
u/VMX Aug 15 '22
I know... I'm the OP :-)
Yes, the migration path for apps with custom navigation talks about migrating the navigation logic to
OnBackPressedDispatcherby implementingOnBackPressedCallback.The point is... I'm not implementing any of that logic myself. I'm just using the push/pop navigation logic from Flutter, so I have no control over that.
I'd expect the Flutter team would take care of this before Android 13 drops, and let us know what we need to do (if anything) to activate the gesture, such as adding that line to the Android Manifest maybe.
But Android 13 final release is only a few weeks away. Hence my question...
15
Aug 14 '22 edited Aug 14 '22
[removed] — view removed comment
5
u/VMX Aug 14 '22 edited Aug 14 '22
So I don't know what this will look like when moving between screens of the same app... mainly because, as far as I can tell, Google has only provided the one GIF, which shows the back transition from Chrome directly to the home screen. I've searched everywhere but I can't find any other examples. Maybe somebody who's developing a native app can shed some light on this.
When I added the above line to my Android Manifest, I can confirm I could see just that - a nice animation where you can take a peek at your home screen before completing the gesture.
But it seems very weird to me that they encourage devs to "get their apps ready" before Android 13 drops, and yet they've provided zero information or docs other than that one page... and nothing at all for the behemoth of an SDK that Flutter is.
And yeah, I think it should be very similar to how the back gesture is already rendered in iOS. In fact, I see this feature as a way to bring some "feature-parity" with iOS in terms of visual navigation cues, which is great.
The one thing that seems difficult is previewing the Home Screen. That would require integration with the OS.
Yep, and that already works if you modify your Android Manifest (at the expense of breaking everything else of course 😅). The system will take care of it.
So in my view, I think the Flutter team just needs to make sure that the standard Flutter navigation system implements this in-app when needed, just like they do today with the existing animations: capture the gesture within Flutter when you still have pages below you in the navigation tree, and hand the gesture off to the system when you're at the root of your navigation tree.
5
Aug 14 '22
[removed] — view removed comment
4
u/VMX Aug 14 '22
Thanks, hand't thought of that. Although I would be really surprised/concerned if nobody at Google or Flutter had already thought of this.
Do you know what the right repo would be for something like this? I've never opened an issue for something as big as Flutter before.
6
12
u/ercantomac Aug 14 '22
Is there a video where this new feature is demonstrated with different examples? Looking at the gif you linked, I don't see why/how this would cause problems.