【发布时间】:2020-04-28 21:20:57
【问题描述】:
我正在导航到我的 Flutter 应用中的下一页。
在下一页有一些用户可以输入文本的表单。
final _form2Key = GlobalKey<FormState>();
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
width: screenWidth / 1.1,
height: screenHeight / 5.5,
child: Form(
key: _form2Key,
autovalidate: true,
child: TextFormField(
autofocus: true,
validator: (val) {
if (val.trim().length < 3 || val.isEmpty) {
return "Too short";
} else if (val.trim().length > 200) {
return "Too long";
} else {
return null;
}
},
onSaved: (val) => description = val,
decoration: InputDecoration(
border: OutlineInputBorder(),
filled: true,
fillColor: Colors.white,
labelText: "",
labelStyle: TextStyle(fontSize: 15.0),
hintText: " ",
),
),
),
),
一切正常,但导航到这个新页面后,键盘会自动显示并集中在文本字段上。
是否可以避免键盘弹出,只在用户按下表单时才显示键盘?
提前致谢!
【问题讨论】: