如何在 Flutter 的 TextField 中禁用预测文本?

sk_*_*462 16 keyboard textfield autocorrect dart flutter

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

我曾尝试使用 autocorrect: false 和更改键盘类型,但它不起作用。

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

Spa*_*atz 21

如果既enableSuggestions不能autocorrect也不能解决问题,请尝试设置keyboardTypeTextInputType.visiblePassword

  • TextInputType.visiblePassword 有效,但我需要键盘中的多行按钮 (2认同)

小智 5

您可以尝试添加enableSuggestions = false到您的文本字段小部件。这应该像https://github.com/flutter/flutter/pull/42550一样禁用键盘上的预测文本。

TextField(
      autocorrect: false,
      enableSuggestions: false,
      keyboardType: TextInputType.emailAddress,
      decoration: new InputDecoration(hintText: "Enter text"),
      autofocus: true,
    ),
Run Code Online (Sandbox Code Playgroud)