Search code examples
flutter

TextInputAction.next not going to next field when has a suffixIcon in Flutter


I have a problem with TextFormField using TextInputAction.next.

When I'm using suffixIcon the focus is on suffixIcon and not on the next field in my form.


Solution

  • My solution was to add a Focus widget to my suffixIcon and set the flags canRequestFocus and descendantsAreFocusable to false.

    Example:

    Widget _suffixIcon() {
      return Focus(
        canRequestFocus: false,
        descendantsAreFocusable: false,
        child: Icon(Icons.person), //Any icon or a custom widget
      );
    }
    TextFormField(
      decoration: InputDecoration(suffix: _suffixIcon()),
      //...
    )