Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在颤振的文本字段中禁用预测文本?_Flutter_Dart_Keyboard_Textfield_Autocorrect - Fatal编程技术网

Flutter 如何在颤振的文本字段中禁用预测文本?

Flutter 如何在颤振的文本字段中禁用预测文本?,flutter,dart,keyboard,textfield,autocorrect,Flutter,Dart,Keyboard,Textfield,Autocorrect,我想禁用文本字段键盘中的预测文本。在原生安卓和IOS中,这并不难,但我还没有找到一个解决方案 我尝试过使用自动更正:false和更改键盘类型,但它不起作用 TextField( autocorrect: false, keyboardType: TextInputType.emailAddress, decoration: new InputDecoration(hintText: "Enter text"),

我想禁用文本字段键盘中的预测文本。在原生安卓和IOS中,这并不难,但我还没有找到一个解决方案

我尝试过使用自动更正:false和更改键盘类型,但它不起作用

TextField(
          autocorrect: false,
          keyboardType: TextInputType.emailAddress,
          decoration: new InputDecoration(hintText: "Enter text"),
          autofocus: true,
        ),

在撰写此答案时,Android尚未提供此功能。但是在iOS上使用autocorrect:false应该可以


检查:

这对我在iOS和android上都有效

                    TextField(
                        autocorrect: false,
                        obscureText: true,
                        controller: answerText,
                        textAlign: TextAlign.center,
                        keyboardType: TextInputType.text,
                        textInputAction: TextInputAction.done,
                        autofocus: true,
                        onChanged: (value) {
                          setState(() {
                            result = value;
                          });
                        },),

唯一的缺点是它在屏幕上模糊了所写的内容。解决方法是在屏幕的某个地方添加
文本(结果)

您可以尝试向textfield小部件添加
enableSuggestions=false
。这将禁用键盘上的预想文本


如果
启用建议
自动更正
都不能解决问题,请尝试将
键盘类型
设置为TextInputType.visiblePassword

因为目前还没有具体的解决方案,请尝试这样做

TextField(
  enableSuggestions: false,
  keyboardType: TextInputType.visiblePassword
)

这确实有效。我想说,这并不明显,而且
启用建议
似乎根本不会改变行为(只是
键盘类型
属性)当
keyboardType
设置为visiblePassword

TextInputType以外的任何其他选项时,这不起作用。visiblePassword可以工作,但我需要键盘上的多行按钮
TextField(
  enableSuggestions: false,
  keyboardType: TextInputType.visiblePassword
)