build method
Widget
Implementation
@override
Widget build(BuildContext context) {
return TextField(
textAlign: textAlign,
onChanged: onChanged,
onSubmitted: onSubmitted,
onTap: onTap,
controller: controller,
maxLines: maxLines,
maxLength: maxLength,
keyboardType: keyboardType,
textInputAction: textInputAction,
autofocus: autofocus,
focusNode: focusNode,
enabled: enable,
inputFormatters: keyboardType == TextInputType.number
? [FilteringTextInputFormatter.digitsOnly]
: null, // 只允许输入数字
style: TextStyle(
color: textColor,
fontFamily: fontFamily,
fontSize: fontSize,
fontWeight: fontWeight,
),
decoration: InputDecoration(
isDense: isDense,
contentPadding: EdgeInsets.zero,
hintText: placeholder,
border: InputBorder.none, // 去掉下方的横线
counterText: isShowCounterText ? null : '', // 隐藏默认计数器
hintStyle: TextStyle(
color: placeholderColor,
fontFamily: fontFamily,
fontSize: fontSize,
fontWeight: fontWeight,
),
),
);
}