如何将焦点节点更改为下一个 PInput 小部件

how to change the focus node to next pinput widget

提问人:Nandyala Raja Pragnesh Reddy 提问时间:11/15/2023 更新时间:11/15/2023 访问量:29

问:

如何将焦点节点更改为下一个 PInput 小部件

我尝试将焦点节点对象添加到第二个 pinput 小部件,但没有运气,焦点没有移动到下一个小部件。我想要的是,当第一个小部件文本完成时,键盘焦点应该自动移动到下一个 pinput 小部件

Pinput(
                      //key: UniqueKey(),

                      obscureText: true,
                      obscuringCharacter: '●',
                      separatorBuilder: (index) => SizedBox(width: 18),
                      controller: pinControllerOne,
                      textInputAction: TextInputAction.next,
                      inputFormatters: <TextInputFormatter>[
                        FilteringTextInputFormatter.digitsOnly
                      ],
                      onCompleted: (pin) {
                        debugPrint('onCompleted: $pin');
                       nextEditableTextFocus();

                      },
                      validator: (value) {
                        if (value!.isEmpty || value.length <= 3) {
                          return 'Please enter PIN';
                        }
                        return null;
                      },
                      focusedPinTheme: defaultPinTheme.copyWith(
                        decoration: defaultPinTheme.decoration!.copyWith(
                          borderRadius: BorderRadius.circular(8),
                          border: Border.all(color: Colors.green),
                        ),
                      ),
                      submittedPinTheme: defaultPinTheme.copyWith(
                        decoration: defaultPinTheme.decoration!.copyWith(
                          color: Color.fromRGBO(243, 246, 249, 0),
                          borderRadius: BorderRadius.circular(10),
                          border: Border.all(
                              color: Color.fromRGBO(23, 171, 144, 1)),
                        ),
                      ),
                      defaultPinTheme: defaultPinTheme),
                  SizedBox(height: 20),
                  Container(
                    alignment: Alignment.centerLeft,
                    child: Text('Confirm PIN',
                        style: TextStyle(
                            fontWeight: FontWeight.w500,
                            fontSize: 16,
                            fontFamily: 'CalibriBold',
                            color: Color(0xFF333333))),
                  ),
                  SizedBox(height: 10),
                  Pinput(
                      obscureText: true,
                      obscuringCharacter: '●',
                      focusNode: focus,
                      //key: UniqueKey(),
                      separatorBuilder: (index) => SizedBox(width: 18),
                      textInputAction: TextInputAction.next,
                      //defaultPinTheme: confirmPinTheme,
                      defaultPinTheme: defaultPinTheme,
                      controller: pinControllerTwo,
                      inputFormatters: <TextInputFormatter>[
                        FilteringTextInputFormatter.digitsOnly
                      ],
                      validator: (value) {
                        if (value!.isEmpty || value.length <= 3) {
                          return 'Please enter PIN';
                        }
                        return null;
                      },
                      focusedPinTheme: defaultPinTheme.copyWith(
                        decoration: defaultPinTheme.decoration!.copyWith(
                          borderRadius: BorderRadius.circular(8),
                          border: Border.all(color: Colors.green),
                        ),
                      ),
                      submittedPinTheme: defaultPinTheme.copyWith(
                        decoration: defaultPinTheme.decoration!.copyWith(
                          color: Color.fromRGBO(243, 246, 249, 0),
                          borderRadius: BorderRadius.circular(10),
                          border: Border.all(
                              color: Color.fromRGBO(23, 171, 144, 1)),
                        ),
                      ),
                      onCompleted: (pin) {
                        debugPrint('onCompleted: $pin');
                      }),

我尝试将焦点节点对象添加到第二个 pinput 小部件,但没有运气,焦点没有移动到下一个小部件。我想要的是,当第一个小部件文本完成时,键盘焦点应该自动移动到下一个 pinput 小部件

颤振 飞镖 焦点

评论


答: 暂无答案