1

I have an app with almost 300 textfields and I been using the autofocus and textinputaction properties to go to the next textfield. And it works well for the textfields with a normal keyboard. But when I come to the next part of the form with a numeric keyboard this properties become unreliable and don't always focus the next textfield. I have heard that using Focusnode class would be a a solution but that would emply to make 300 focus nodes and implement them.

I wonder if one of you knows another way to focus to next field in a more reliable and efficient way.

Thanks for your answers!

Examples: [1]: https://i.stack.imgur.com/AZjBz.gif [2]: https://i.stack.imgur.com/kEOnw.png [3]: https://i.stack.imgur.com/wXeGf.png

2 Answers2

0

textInputAction: TextInputAction.next Should work just fine

Ward Suleiman
  • 381
  • 2
  • 10
0

This is how you can solve it.

Form(
  child: SingleChildScrollView(
    padding: EdgeInsets.symmetric(horizontal: 16.0),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        TextFormField(
          textInputAction: TextInputAction.next, // Keyboard with Next arrow
          autofocus: true, // Place cursor on this field at start up
          decoration: InputDecoration(labelText: "First field"),
        ),
        TextFormField(
          textInputAction: TextInputAction.next,
          decoration: InputDecoration(labelText: "Second field"),
        ),
      ],
    ),
  ),
);
Constantin N.
  • 2,739
  • 2
  • 16
  • 27
  • Thanks for your feedback! I already tried that. And it didn't work with me. I had to use focusnodes and now it works perfectly. Thanks nonetheless for your attention! – Daniel Reynoso Aug 10 '21 at 18:23