1 | initial version |
To turn off the default phone keyboard when a user clicks on a Text input in Flutter, you can use the following code snippet:
TextEditingController _controller = TextEditingController();
FocusNode _focusNode = FocusNode();
GestureDetector(
onTap: () {
_focusNode.requestFocus();
FocusScope.of(context).requestFocus(FocusNode());
},
child: TextFormField(
controller: _controller,
focusNode: _focusNode,
decoration: InputDecoration(
hintText: "Enter text",
),
),
),
This will set the focus on the Text input and then remove focus, which will hide the keyboard.