Search code examples
flutterdartandroid-softkeyboard

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


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


Solution

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

    onSubmitted: (val) => searchNumber(),