How to hide soft input keyboard on flutter after clicking outside TextField/anywhere on screen?

后端 未结 16 2021
甜味超标
甜味超标 2020-12-08 01:54

Currently, I know the method of hiding the soft keyboard using this code, by onTap methods of any widget.

FocusScope.of(context).requestFocus(new         


        
16条回答
  •  星月不相逢
    2020-12-08 02:16

    This is best

    Scaffold(
    body: GestureDetector(
      onTap: () {
       if (messageFocusNode.hasFocus) {
         messageFocusNode.unfocus();
     }
    },
    child: new Container(
       //rest of your code write here
        )
     )
    

提交回复
热议问题