How to shift focus to next textfield in flutter?

前端 未结 7 2097
甜味超标
甜味超标 2020-12-04 23:36

I am new to Flutter.

I am building a form with multiple text inputs using following widgets: Form, TextFormField. The keyboard that appears doesn\'t show \"next\" (w

7条回答
  •  攒了一身酷
    2020-12-05 00:12

    For me this worked it moves to next input on entering first digit

    Row(
                      children: [
                        Expanded(
                          child: TextFormField(
                            textInputAction: TextInputAction.next,
                            onChanged: (_) => FocusScope.of(context).nextFocus(),
                              controller:c1 ,)
                        ),
                        SizedBox(
                          width: 20.0,
                        ),
                        Expanded(
                          child: TextFormField(
                            textInputAction: TextInputAction.next,
                            onChanged: (_) => FocusScope.of(context).nextFocus(),
                              controller:c2 ,),
                        ),
                        SizedBox(
                          width: 20.0,
                        ),
                        Expanded(
                          child: TextFormField(
                              controller:c3 ,
                            textInputAction: TextInputAction.next,
                            onChanged: (_) => FocusScope.of(context).nextFocus(),),
                        ),
                        SizedBox(
                          width: 20.0,
                        ),
                        Expanded(
                          child: TextFormField(
                              controller:c4 ,
                            textInputAction: TextInputAction.next,
                            onChanged: (_) => FocusScope.of(context).nextFocus(),),
                        ),
                        SizedBox(
                          width: 20.0,
                        ),
                        Expanded(
                          child: TextFormField(
    
                              controller:c5 ,
                            textInputAction: TextInputAction.next,
                            onChanged: (_) => FocusScope.of(context).nextFocus(),),
                        ),
                        SizedBox(
                          width: 20.0,
                        ),
                        Expanded(
                          child: TextFormField(
                              controller:c6 ,
                            textInputAction: TextInputAction.next,
                            onChanged: (_) => FocusScope.of(context).unfocus(),
                              ),
                        )
                      ],
                    )
    

提交回复
热议问题