-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Is there idea FlutterView(Android) intercept the 'back' keydown? #4867
Comments
You'll want to add something like this to your activity: @Override
public void onBackPressed() {
if (flutterView != null) {
flutterView.popRoute();
return;
}
super.onBackPressed();
} |
But if FlutterView has no any route can pop, and the app should exit(in my usecase), is there a way to check the route can pop? |
If you try to pop a route and the view doesn't have a route that it can pop, it will end the current activity: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/binding.dart#L166 |
OH, it is clear in my case.And if I want to do other thing(not pop a route) just make a toast or make a dialog in FlutterView, how can do it? |
You can add a WidgetsBindingObserver that listens to |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
No description provided.
The text was updated successfully, but these errors were encountered: