bool isKeyboardVisible = false; @override void initState() { super.initState(); KeyboardVisibilityNotification().addNewListener( onChange: (bool visible) { isKeyboardVisible = visible; }, ); }