安卓工作室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
属性并为其分配 TextInputAction.next
枚举即可。这将在键盘上显示下一个按钮。 FocusScope 将允许您更改键盘焦点。这里我刚刚使用了nextFocus()当按下下一个按钮时,将键盘焦点更改为下一个 TextFormField。
TextFormField(
...
textInputAction: TextInputAction.next,
onFieldSubmitted: (value){
FocusScope.of(context).nextFocus();
}
...
)
有关更多 textInputAction
类型,请查看此 TextInputAction documentation
关于android - 软键盘中不显示下一步按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60835765/