简体   繁体   English

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

[英]Not show Next button in the soft keyboard

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

Here result:结果如下:

在此处输入图片说明

The focus is on first field text (email).重点是第一个字段文本(电子邮件)。 But on soft keyboard not show Next button (green button).但在软键盘上不显示下一步按钮(绿色按钮)。 Show Done button.显示完成按钮。 Why?为什么?

You need to specify the textInputAction property to get that behaviour.您需要指定textInputAction属性以获取该行为。

TextFormField(
   decoration: new InputDecoration(hintText: 'Email'),
   keyboardType: TextInputType.emailAddress,
   textInputAction: TextInputAction.next,
   onChanged: (value) {
      setState(() {
         _email = value;
      });
   }
)

Refer TextInputAction for all the available types有关所有可用类型,请参阅TextInputAction

Just add textInputAction property and assign TextInputAction.next enum to it.只需添加textInputAction属性并将TextInputAction.next枚举分配给它。 This will display the next button on the keyboard.这将显示键盘上的下一个按钮。 FocusScope will allow you to change the keyboard focus. FocusScope 将允许您更改键盘焦点。 Here I just used nextFocus() to change the keyboard focus to the next TextFormField when pressing the next button.在这里,我只是使用nextFocus()在按下下一个按钮时将键盘焦点更改为下一个 TextFormField。

TextFormField( 
  ...
  textInputAction: TextInputAction.next,
  onFieldSubmitted: (value){
    FocusScope.of(context).nextFocus();
  }
  ...
)

For more textInputAction types, please have a look at this TextInputAction documentation有关更多textInputAction类型,请查看此TextInputAction 文档

If you wanna see next button in the keyboard should如果你想在键盘上看到下一个按钮应该

TextFormField( 
  ...
  textInputAction: TextInputAction.next,
  ...
)

But this alone will not focus on next input field.但仅此一项不会关注下一个输入字段。

Please check: https://medium.com/flutterpub/flutter-keyboard-actions-and-next-focus-field-3260dc4c694 or How to shift focus to next textfield in flutter?请检查: https : //medium.com/flutterpub/flutter-keyboard-actions-and-next-focus-field-3260dc4c694如何在flutter中将焦点转移到下一个文本字段?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM