簡體   English   中英

軟鍵盤中不顯示下一步按鈕

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM