Keyboard is pushing the FloatingActionButton upward in flutter app
I had the same issue, where my Floating Action Button would get pushed up.
I solved this using the property:
resizeToAvoidBottomPadding: false, // fluter 1.xresizeToAvoidBottomInset: false // fluter 2.x
On the parent Scafold
.
I tested it with your code, it solves the issue as well.
You can check if the keyboard is show up or not, and based on that create the floating button or not.
@override Widget build(BuildContext context) { return Scaffold( floatingActionButton: keyboardIsOpened ? null ://or an empty container FloatingActionButton( tooltip: 'Add Item', child: Icon(Icons.add), backgroundColor: Colors.red, onPressed: _showFormDialog, ), ); }
Inside the build method you can know if the keyboard show up by using MediaQuery.of(context).viewInsets.bottom
and save its value on a bool variable keyboardIsOpened
like the following code.
@overrideWidget build(BuildContext context) { bool keyboardIsOpened = MediaQuery.of(context).viewInsets.bottom != 0.0;
Used MediaQuery
and Visibility
widget
Visibility( visible: MediaQuery.of(context).viewInsets.bottom != 0.0, child: FloatingActionButton( onPressed: () { }, child: Icon(Icons.chat), ), ),