Warm tip: This article is reproduced from stackoverflow.com, please click
android-softkeyboard dart flutter

How to handle keyboard actions or add functions in keyboard TextInputAction in Flutter/Dart?

发布于 2020-07-24 15:43:17

I have simple TextField below. I wanted to call my search function when I pressed the TextInputAction button of the SofInput Keyboard.

TextField(
    keyboardType: TextInputType.phone,
    textInputAction: TextInputAction.search,
    decoration: InputDecoration(hintText: 'Enter Number'),
),

// Example only
void myCustomFunction() => SearchNumber();

enter image description here

Questioner
luhluh
Viewed
27
Hiwa Jalal 2020-05-02 07:05

when you press that button the onSumbitted method get called so you can do this:

onSubmitted: (val) => searchNumber(),