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

后端 未结 16 2023
甜味超标
甜味超标 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:14

    Wrap whole screen in GestureDetector as

    new Scaffold(
    
      body: new GestureDetector(
          onTap: () {
            // call this method here to hide soft keyboard
            FocusScope.of(context).requestFocus(new FocusNode());
          },
        child: new Container(
           -
           -
           -
            )
       )
    

提交回复
热议问题