2

I try to make a TextField with keyboardType: TextInputType.visiblePassword to disable the predictive text but with that I can't go to a new line because it's a submit button. I try to add textInputAction: TextInputAction.newline but don't work too.

My TextField:

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])
))));
5
  • You could try setting maxLines: property to 2 or whatever you want it to be. Commented Jul 22, 2021 at 8:46
  • I try but dont' work =/ Commented Jul 22, 2021 at 9:38
  • Probably because TextInputType.visiblePassword disables multiline as passwords are always single line fields. Commented Jul 22, 2021 at 9:46
  • Yes it's what I think, but I need to disable the predictive text and to have a new line. TextInputType.multiline don't work too. Commented Jul 22, 2021 at 9:53
  • You can set maxlines to null or pass any integer value TextField( keyboardType: TextInputType.multiline, maxLines: null, ), Commented Jan 18, 2024 at 3:52

6 Answers 6

9

You just add below parameter to disable predicting text.

enableSuggestions: false,
autocorrect: false,

But to enable multiline, you need to change 'keyboardType' to '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]))
Sign up to request clarification or add additional context in comments.

1 Comment

I already do that but if I put keyboardType: TextInputType.multiline, the predicting text comes back even if I put "enableSuggestions: false, autocorrect: false"
1

if next line button show inside keyboard, so use only two line

  keyboardType: TextInputType.multiline,
  textInputAction: TextInputAction.newline,

Comments

1

Change TextInputAction.newline to TextInputAction.next

TextField(
          focusNode: myFocusNode,
          autocorrect: false,
          enableSuggestions: false,
          toolbarOptions:
             const 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],
          ),
        ),

1 Comment

The same issue, it's don't work. When I pressed the button nothing past.
1
 keyboardType: TextInputType.multiline,
 textInputAction: TextInputAction.newline,
 maxLines: null,

This should give you ability to jump line when pressing enter

Comments

0

I add my textfield in a RawKeyboardListener and when user press "Enter" it's detect automatically.

RawKeyboardListener(
      focusNode: FocusNode(),
      onKey: (event) {
             if(event.isKeyPressed(LogicalKeyboardKey.enter)) {
                 int cursorPos = textEditor.selection.base.offset;
                 textEditor.text = textDebut + '\n' + textFin;
                 textEditor.selection = TextSelection.fromPosition(TextPosition(offset: cursorPos + 1));}},
child: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]),
      onChanged: (String text) {print(text);}))

Comments

0

add this line : textInputAction: TextInputAction.newline, remove this line : keyboardType: TextInputType.text,

TextField(
           //keyboardType: TextInputType.text,
             textInputAction: TextInputAction.newline,
             maxLines: 30,
             decoration: InputDecoration(
             border: InputBorder.none,
             labelStyle: greyTextStyle400,
             hintStyle: greyTextStyle400,
             hintText: "Message...",
            ),
          ),

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.