Reputation: 110
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])
))));
Upvotes: 1
Views: 6407
Reputation: 11
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.newline,
maxLines: null,
This should give you ability to jump line when pressing enter
Upvotes: 1
Reputation: 14785
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],
),
),
Upvotes: 1
Reputation: 277
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...",
),
),
Upvotes: 0
Reputation: 531
if next line button show inside keyboard, so use only two line
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.newline,
Upvotes: 1
Reputation: 110
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);}))
Upvotes: 0
Reputation: 7492
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]))
Upvotes: 8