Search code examples
flutterdartflutter-textformfieldflutter-windows

Move to next input field on pressing Tab in Flutter Windows Application


I have a form with multiple TextFormField. I would like for the user to be able to move to the next field using tab or go back using Shift+Tab. The page looks as follows:

enter image description here

When I focus on Contract Number field and press tab, instead of going to composition field it goes to Invoices written in the Side Navigation which is created using NavigationRail. And on pressing tab again it moves to Payments. And on third tab it moves to Composition Text Field.

Is there a way I can fix the order in which this happens?


Solution

  • You can create a traversal group. For example if you have 10 elements in a column you can wrap the column and add a policy

    FocusTraversalGroup(
          policy: OrderedTraversalPolicy()
          child: Column(),
     )
    

    More info focusTraversalGroup