Replies: 1 comment
-
For those who come across this post. I ended up tracking the state of the drawer and, if the drawer is open, not ask the confirmation question. class HomeScreenState extends State<ClientScaffold> {
bool _isDrawerOpen = false;
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () => _handleAndroidBackButton(context),
child: Scaffold(
...
onDrawerChanged: (isOpened) => _isDrawerOpen = isOpened,
),
);
}
Future<bool> _handleAndroidBackButton(BuildContext context) async {
if (_isDrawerOpen) return true;
...
}
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I want to implement the following behavior in my Flutter application:
If the users presses the Android back button or uses the back gesture, then
if the user has enabled the predictive back gesture, then Android system animation should be shownHow can I implement this behavior with AutoRoute?
About the predictive back gesture: My understanding is that in Android 14
android:enableOnBackInvokedCallback="true"
in the manifest andHowever, the application can't seem to detect whether the user has enabled predictive back. And if the flag is set, then the application does close immediately regardless (no callback). Plus: only a few users use this feature already. Therefore my thinking is to use an "exit dialog" for the time being.
One implementation I tried is using WillPopScope around in my root scaffold.
This is the gist:
Full code sample
That works only partially.
Beta Was this translation helpful? Give feedback.
All reactions