[英]Not show Next button in the soft keyboard
安卓工作室 3.6
@override
Widget build(BuildContext context) {
logger.d("build:");
//String _errorMessage = null;
return Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
centerTitle: true,
title: new Text('Sign in',
style: TextStyle(fontWeight: FontWeight.bold))),
body: new Container(
margin: const EdgeInsets.only(
left: Constants.DEFAULT_MARGIN,
right: Constants.DEFAULT_MARGIN),
child: new Form(
key: _formKey,
child: new Column(children: [
new TextFormField(
decoration: new InputDecoration(hintText: 'Email'),
keyboardType: TextInputType.emailAddress,
onChanged: (value) {
setState(() {
_email = value;
});
}),
new TextFormField(
decoration: new InputDecoration(hintText: 'Password'),
obscureText: true,
onChanged: (value) {
setState(() {
_password = value;
});
})
]))));
}
结果如下:
重点是第一个字段文本(电子邮件)。 但在软键盘上不显示下一步按钮(绿色按钮)。 显示完成按钮。 为什么?
您需要指定textInputAction
属性以获取该行为。
TextFormField(
decoration: new InputDecoration(hintText: 'Email'),
keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.next,
onChanged: (value) {
setState(() {
_email = value;
});
}
)
有关所有可用类型,请参阅TextInputAction
只需添加textInputAction
属性并将TextInputAction.next
枚举分配给它。 这将显示键盘上的下一个按钮。 FocusScope 将允许您更改键盘焦点。 在这里,我只是使用nextFocus()在按下下一个按钮时将键盘焦点更改为下一个 TextFormField。
TextFormField(
...
textInputAction: TextInputAction.next,
onFieldSubmitted: (value){
FocusScope.of(context).nextFocus();
}
...
)
有关更多textInputAction
类型,请查看此TextInputAction 文档
如果你想在键盘上看到下一个按钮应该
TextFormField(
...
textInputAction: TextInputAction.next,
...
)
但仅此一项不会关注下一个输入字段。
请检查: https : //medium.com/flutterpub/flutter-keyboard-actions-and-next-focus-field-3260dc4c694或如何在flutter中将焦点转移到下一个文本字段?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.