Want to hide FAB when onscreen keyboard appear? You can achieve it by checking for keyboard visibility using viewInsets and hide fab based on it.
Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import 'package:flutter/material.dart'; void main() { runApp(new MaterialApp( title: "Example", home: new FabHideOnKeyboard(), )); } class FabHideOnKeyboard extends StatefulWidget { @override _FabHideOnKeyboardState createState() => new _FabHideOnKeyboardState(); } class _FabHideOnKeyboardState extends State<FabHideOnKeyboard> { @override Widget build(BuildContext context) { final bool showFab = MediaQuery.of(context).viewInsets.bottom==0.0; return Scaffold( resizeToAvoidBottomPadding: true, body:Container( alignment: Alignment.center, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text("TextField:"), TextField() ], ), ), floatingActionButton: showFab?Icon(Icons.add):null, ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.