Flutter 如何在颤振的文本字段中禁用预测文本?
我想禁用文本字段键盘中的预测文本。在原生安卓和IOS中,这并不难,但我还没有找到一个解决方案 我尝试过使用自动更正:false和更改键盘类型,但它不起作用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"),
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
设置为visiblePasswordTextInputType以外的任何其他选项时,这不起作用。visiblePassword可以工作,但我需要键盘上的多行按钮
TextField(
enableSuggestions: false,
keyboardType: TextInputType.visiblePassword
)