[英]How to keep focus on TextField but not display keyboard in Flutter?
I am new to Flutter.我是 Flutter 的新手。 The thing I want is to keep focus on TextField, but not display keyboard.
我想要的是专注于 TextField,而不是显示键盘。 Is it possible?
是否可以?
To give focus to a text field as soon as it's visible, use the autofocus property.要在文本字段可见时立即为其提供焦点,请使用 autofocus 属性。
content_copy
TextField(
autofocus: true,
);
_dismissKeyboard(BuildContext context) {
FocusScope.of(context).requestFocus(new FocusNode());
}
@override
Widget build(BuildContext context) {
return new GestureDetector(
onTap: () {
this._dismissKeyboard(context);
},
child: new Container(
color: Colors.white,
child: new Column(
children: <Widget>[/*...*/],
),
),
);
}
Both of these components should be used together to implement what you are trying to acheive.这两个组件应该一起使用来实现您想要实现的目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.