Flutter - 文本字段添加新行

Fla*_*eil 1 textfield dart flutter

我尝试创建一个 TextField 来keyboardType: TextInputType.visiblePassword禁用预测文本,但我无法转到新行,因为它是一个提交按钮。我尝试添加textInputAction: TextInputAction.newline但也不起作用。

我的文本字段:

TextField(
     focusNode: myFocusNode,
     autocorrect: false,
     enableSuggestions: false,
     toolbarOptions: ToolbarOptions(copy: false, cut: false, paste: false),
     keyboardType: TextInputType.visiblePassword,
     textInputAction: TextInputAction.newline,
     autofocus: true,
     maxLines: null,
     controller: textEditor,
     decoration: InputDecoration(fillColor: Colors.grey[100])
))));
Run Code Online (Sandbox Code Playgroud)

KuK*_*uKu 7

您只需添加以下参数即可禁用预测文本。

enableSuggestions: false,
autocorrect: false,
Run Code Online (Sandbox Code Playgroud)

但要启用多行,您需要将“keyboardType”更改为“TextInputType.multiline”。

TextField(
        autocorrect: false,
        enableSuggestions: false,
        toolbarOptions: ToolbarOptions(copy: false, cut: false, paste: false),
        keyboardType: TextInputType.multiline,
        textInputAction: TextInputAction.newline,
        autofocus: true,
        maxLines: null,
        decoration: InputDecoration(fillColor: Colors.grey[100]))
Run Code Online (Sandbox Code Playgroud)