DEV Community

Vishnu Reji
Vishnu Reji

Posted on

Flutter : Detect keyboard open and close without using a external package

Step 1
Create a variable

bool _keyboardVisible = false;
Enter fullscreen mode Exit fullscreen mode

in StatefullWidget
Step 2
Then initialize that variable in the build widget;

@override
Widget build(BuildContext context) {
    _keyboardVisible = MediaQuery.of(context).viewInsets.bottom != 0;
    return child;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)