I want to detect if the keyboard is visible. I could implement the hacks that were suggested on other stackoverlfow threads:
bool keyboardvisible = MediaQuery.of(context).viewInsets.bottom > 0;
and this works for Android, but on iOS this bottom property always seems to return 0, no matter if the keyboard is visible or not.
Is there any better approach to detect keyboard visibility that actually works on both platforms?
Thnx John
this plugin will help you. It provides a listener for visibility change for both iOS and Android.
Example Code:
import 'package:keyboard_visibility/keyboard_visibility.dart';
@protected
void initState() {
super.initState();
KeyboardVisibilityNotification().addNewListener(
onChange: (bool visible) {
print(visible);
},
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With