2

输入 OTP 时没有光标,如何在 pinFieldAutoFill 中添加光标。我正在使用 sms_autofill: ^1.2.5 包。

                                 PinFieldAutoFill(
                                        autofocus: true,
                                        keyboardType: TextInputType.number,
                                        decoration: UnderlineDecoration(
                                          textStyle: TextStyle(
                                              fontSize: 44.sp,
                                              fontWeight: FontWeight.bold,
                                              color: kDarkBlue),
                                          colorBuilder: FixedColorBuilder(
                                              Colors.grey),
                                        ),
                                        currentCode: authService
                                            .loginMobileOTP, // prefill with a code
                                        onCodeSubmitted: (_) async {
                                          authService.login(
                                              context, _scaffoldKey);
                                        },
                                        onCodeChanged: (value) {
                                          authService.loginMobileOTP =
                                              value;
                                        },
                                        codeLength:
                                            6 //code length, default 6
                                        ),
4

1 回答 1

1

请在“sms_autofill”包、类构造器“PinInputTextField”中启用光标选项。

分享参考代码

return PinInputTextField(
  pinLength: widget.codeLength,
  decoration: widget.decoration,
  cursor: Cursor(
    width: 2,
    height: 40,
    color: Colors.red,
    radius: Radius.circular(1),
    enabled: true,
  ),
于 2021-03-03T12:27:59.537 回答