android 如何在flutter的pinfieldautofill()中设置选中和启用的边框颜色

ugmeyewa  于 2022-12-21  发布在  Android
关注(0)|答案(1)|浏览(135)
PinFieldAutoFill(
                      currentCode: codevalue,
                      autoFocus: true,
                      focusNode: myfocusnode,
                      codeLength: 6,
                      cursor: Cursor(
                        width: 2,
                        height: 20,
                        color: Colors.red,
                        radius: Radius.circular(1),
                        enabled: true,
                      ),
                      textInputAction: TextInputAction.done,
                      decoration: BoxLooseDecoration(
                          radius: Radius.circular(10.0),
                          bgColorBuilder: FixedColorBuilder(
                              Color.fromARGB(255, 255, 255, 255)),
                          strokeColorBuilder: FixedColorBuilder(Colors.black),
                          gapSpace: 16),

这是我的代码,我只想在pinfieldautofill()中添加选定和启用的边框颜色

axr492tv

axr492tv1#

您可以使用下面的软件包,定制也很容易:
https://pub.dev/packages/pin_code_fields
您可以在小部件中使用pinTheme参数来更改大头针边框或颜色以及形状。请参见实现代码:

PinCodeTextField(
                        appContext: context,
                        pastedTextStyle: TextStyle(
                          color: Colors.green.shade600,
                          fontWeight: FontWeight.bold,
                        ),
                        length: 6,
                        obscureText: false,
                        animationType: AnimationType.fade,
                        hintCharacter: '*',
                        textStyle: TextStyle(
                            color: ColorUtils.blackText,
                            fontSize: FontSize.title24,
                            fontWeight: FontWeight.w700),
                        pinTheme: PinTheme(
                          shape: PinCodeFieldShape.box,
                          borderRadius: BorderRadius.circular(4),
                          fieldHeight: SizeConfig.blockSizeVertical! * 8,
                          fieldWidth: SizeConfig.blockSizeHorizontal! * 13,
                          inactiveFillColor: ColorUtils.textFieldBG,
                          inactiveColor: ColorUtils.cancelRed,
                          selectedColor: Colors.black,
                          activeFillColor: ColorUtils.textFieldBG,
                          activeColor: ColorUtils.inputBorder,
                          selectedFillColor: ColorUtils.textFieldBG,
                        ),
                        cursorColor: Colors.black,
                        animationDuration: const Duration(milliseconds: 300),
                        enableActiveFill: true,
                        controller: _controller.textEditingController,
                        keyboardType: TextInputType.number,
                        inputFormatters: [FilteringTextInputFormatter.digitsOnly],
                        onCompleted: (v) {
                          _controller.checkOtpCode();
                        },
                        onChanged: (value) {
                          //   setState(() {});
                        },
                      ),

相关问题