Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change Text Input Action Button (return/enter key) on Keyboard in Flutter?

Tags:

flutter

dart

In Android and iOS it is possible to change the enter/return key of the keyboard to e.g. a "Go" button (and other options).

illustration

On top, we can see the regular "Return" button on both systems, which is the one you get by default with no modifications in both Android & iOS native and Flutter.

Below that, there is another setting, again on both systems, which you can simply adjust in your native application. It is the "Go" button in this case.

like image 602
creativecreatorormaybenot Avatar asked Apr 30 '18 19:04

creativecreatorormaybenot


People also ask

What is TextInputAction Flutter?

The term TextInputAction. newline exists in Flutter but not in Android or iOS. The reason for introducing this term is so that developers can achieve the common result of inserting new lines without needing to understand the various IME actions on Android and return keys on iOS. Thus, TextInputAction.

How do you change the input value in Flutter?

Reading input value In Flutter, this can be done using TextEditingController . First, create a TextEditingController and set it as a controller property of your TextField widget. In this example, I have added an extra Button and Text widget which will show the added text when you click the “Show Text” button.


2 Answers

The input action for a TextField (or TextFormField) can be specified like this (here, the Go button):

TextField(   textInputAction: TextInputAction.go   ... ) 

List of all available input actions.

like image 58
creativecreatorormaybenot Avatar answered Sep 21 '22 19:09

creativecreatorormaybenot


This is how you can use textInputAction:

TextField(   textInputAction: TextInputAction.search,   onSubmitted: (value) {     print("search");   },   decoration: InputDecoration(     border: InputBorder.none,     prefixIcon: Icon(Icons.search),     hintText: 'Search ',     contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),   ), ); 
like image 28
Mr. RasTazZ Avatar answered Sep 19 '22 19:09

Mr. RasTazZ