android - 软键盘中不显示下一步按钮

标签 android flutter

安卓工作室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;
                        });
                      })
                ]))));
  }

结果如下:

enter image description here

焦点位于第一个字段文本(电子邮件)。但在软键盘上不显示下一步按钮(绿色按钮)。显示完成按钮。 为什么?

最佳答案

只需添加 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/

相关文章:

dart - SharedPreferences 在 null flutter 上调用

json - 如何将动态复杂的 json 解析为 dart 对象或模型

android - 在后台更新位置?

android - Dagger 可以在 Android 中执行 View 对象的注入(inject)吗

android - 谷歌地图上的当前位置

java - 从 parse.com 接收文本文件并放置在 textview 中

flutter - 如何解决Flutter错误Column的children不能包含任何null值,但在索引0处发现null值?

flutter - 如何在 map 抖动中将网络图像(也可以自定义此图像)显示为标记

java - 时间选择器每分钟执行计划任务,直到达到设定时间,而不是仅在设定时间执行

android测试访问json文件