如何为 PinFieldAutoFill 颤动添加光标

问题描述

进入OTP时没有光标,如何在pinFieldAutoFill中添加Cursor。我正在使用 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
                                        ),

解决方法

请在“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,),