Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Textfield add new line

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])
))));
like image 523
ACA Avatar asked Nov 18 '25 01:11

ACA


1 Answers

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]))
like image 92
KuKu Avatar answered Nov 20 '25 14:11

KuKu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!