美文网首页
flutter 点击回车(return)键 禁止键盘下落

flutter 点击回车(return)键 禁止键盘下落

作者: writeSpace | 来源:发表于2023-02-16 18:51 被阅读0次
    实现 onEditingComplete即可
    

    flutter键盘 return 键回调 实现这个方法之后 点击键盘将不会下落

     new TextField(
                    // textInputAction:TextInputAction.newline,
                    onEditingComplete: (){
    
                      // FocusScope.of(context).requestFocus(_backNode);
                      // FocusScopeNode focusScopeNode = FocusScope.of(context);
                      // // if (!focusScopeNode.hasPrimaryFocus &&
                      // //     focusScopeNode.focusedChild != null) {
                      //   FocusManager.instance.primaryFocus!.unfocus();
                      // }
                      print('onEditingComplete11111');
                    },
                    onTap: () {
                      print("ohao ");
                    },
    // focusNode: _backNode,
                    // onSubmitted: (String str) {
                    //   //onSubmitted是用户提交而触发的回调{当用户点击提交按钮(输入法回车键)}
                    //   print('最终手机号为:$str---------------');
                    // },
                    controller: _userPasswordController,
                    keyboardType: TextInputType.multiline,
                    decoration: new InputDecoration(
                        contentPadding: const EdgeInsets.all(10.0),
                        icon: new Icon(Icons.nature_people),
                        labelText: "请输入名字",
    //                  hintText: "fdsfdss",
                        helperText: "注册名字"),
                  ),
    

    相关文章

      网友评论

          本文标题:flutter 点击回车(return)键 禁止键盘下落

          本文链接:https://www.haomeiwen.com/subject/tggpkdtx.html