Flutter pinput 小部件如何更改错误警报文本参数,如文本颜色、大小和字体?我根本无法更改错误警报文本样式。我在 Pinput() 中的代码是
errorPinTheme: defaultPinTheme.copyWith(
decoration: BoxDecoration(
color: AppColors.secondary.redLight,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.redAccent),
),
textStyle: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.w400,
color: Color(0xFFE0193D),
),
),
没有更改 TextStyle 的选项。只有我发现了一个变体,在 otp 小部件的底部添加投射文本。 errorPinTheme 使不可见且几乎没有尺寸:
final errorPinTheme = PinTheme(
width: 0,
height: 0,
textStyle: const TextStyle(
fontSize: 0,
color: Colors.transparent,
),
decoration: BoxDecoration(
color: fillColor,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: borderColor),
),
);
and in the Column(
children: [ ... //
errorPinTheme: errorPinTheme,
submittedPinTheme: defaultPinTheme.copyWith(
decoration: defaultPinTheme.decoration!.copyWith(
color: fillColor,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: focusedBorderColor),
),
),
),
),
),
if (currentErrorMessage != null)
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
currentErrorMessage!,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Color(0xFFE0193D),
),
textAlign: TextAlign.left,
),
),