-
Notifications
You must be signed in to change notification settings - Fork 398
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
How to handle android back button #2
Comments
Yes, this is the question I wanted to ask too. I don't think this support the android back button navigation yet, anyhow see how does @BilalShahid13 reply on this. |
Hi, There is no perfect solution at the moment as android doesn't allow us to override the back button. There is a work around though and you can use the flutter package This is the reason I had to add the |
If you want to just prevent the unintended closure of the app, I would suggest using Offical Documentation: https://api.flutter.dev/flutter/widgets/WillPopScope-class.html Wrap your widget inside Example:
|
I think I should mention it in the Readme as this is a genuine issue with only a workaround available at the moment. Thank you for pointing it out. I will not close this issue yet so if anyone has a better solution he might share here FingersCrossed :D |
The issue where the app closes if android's back button is pressed is fixed in latest version |
great component thanks! any eta on a back button fix for Android ? |
Now app is not exiting at all |
I have fixed it 🎉 New version will be hopefully up tomorrow after l update the sample project and the readme. Stay tuned! |
Noted! Stay tuned for the next version with the fix which I will hopefully release tomorrow. |
Version I'm closing this issue for now 🎉 |
What about changing the first scenario from How can I achieve this? |
It's not possible at the moment but I'll release an update soon with this feature. Stay tuned! |
Hi! If I do this, onWillPop isn't executed. Is there a way to make this work? @override
Widget build(BuildContext context) {
return WillPopScope(
child: Scaffold(...),
onWillPop: () => showDialog<bool>(
context: context,
builder: (c) => AlertDialog(
title: Text('Warning'),
content: Text('Do you really want to exit'),
actions: [
FlatButton(
child: Text('Yes'),
onPressed: () => Navigator.pop(c, true),
),
FlatButton(
child: Text('No'),
onPressed: () => Navigator.pop(c, false),
),
],
),
),
);
} |
@fernando-s97 try to use the |
Hi,
Can you please provide your input on how can we handle the hardware back button when the view is pushed.
Right now when tapping the hardware back button closes the app.
Thanks.
The text was updated successfully, but these errors were encountered: