【问题标题】:How to add cursor For PinFieldAutoFill flutter如何为 PinFieldAutoFill 颤振添加光标
【发布时间】:2021-04-22 21:34:21
【问题描述】:

进入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
                                        ),

【问题讨论】:

  • 这个问题解决了吗?寻找类似的解决方案。

标签: flutter flutter-layout flutter-packages fluttermap


【解决方案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,
  ),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-09
    • 2021-12-26
    • 2019-02-17
    • 1970-01-01
    • 2021-06-05
    • 2018-11-06
    • 2020-05-14
    • 2023-03-18
    相关资源
    最近更新 更多