TLNumberTextField constructor
TLNumberTextField({
- Key? key,
- String? defaultValue,
- String? hintText,
- int? maxLength,
- int? maxIntegerLength,
- int? maxDecimalLength,
- TextStyle? style,
- TextStyle? hintStyle,
- TextAlign? textAlign,
- TextInputType? keyboardType = const TextInputType.numberWithOptions(decimal: true),
- List<
TextInputFormatter> ? inputFormatters, - dynamic onChange()?,
- bool enable = true,
- dynamic onSubmit()?,
- FocusNode? focusNode,
- EdgeInsetsGeometry? contentPadding,
- InputBorder? border,
- InputBorder? enableBorder,
- InputBorder? disableBorder,
- InputBorder? focusBorder,
- dynamic onDispose()?,
- dynamic onFocusChange()?,
- InputDecoration? inputDecoration,
Implementation
TLNumberTextField({
Key? key,
String? defaultValue,
String? hintText,
int? maxLength,
int? maxIntegerLength,
int? maxDecimalLength,
TextStyle? style,
TextStyle? hintStyle,
TextAlign? textAlign,
TextInputType? keyboardType = const TextInputType.numberWithOptions(decimal: true),
List<TextInputFormatter>? inputFormatters,
Function(String)? onChange,
bool enable = true,
Function(String)? onSubmit,
FocusNode? focusNode,
EdgeInsetsGeometry? contentPadding,
InputBorder? border,
InputBorder? enableBorder,
InputBorder? disableBorder,
InputBorder? focusBorder,
final Function()? onDispose,
final Function(bool)? onFocusChange,
final InputDecoration? inputDecoration,
}) : super(
key: key,
defaultValue: defaultValue,
hintText: hintText,
maxLength: maxLength,
style: style,
hintStyle: hintStyle,
textAlign: textAlign,
keyboardType: keyboardType,
inputFormatters: inputFormatters ??
[
//文本长度限制
LengthLimitingTextInputFormatter(maxLength),
//只允许输入小数
FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
//FilteringTextInputFormatter.allow(RegExp("[0-9.]")),但这种限制会有问题,比如可以输入0.1.1这种其实就不是小数了,并且不能限制小数点的输入位数。
TLNumberTextInputFormatter(maxIntegerLength: maxIntegerLength, maxDecimalLength: maxDecimalLength, isAllowDecimal: true),
],
onChange: onChange,
enable: enable,
onSubmit: onSubmit,
focusNode: focusNode,
contentPadding: contentPadding,
border: border,
enableBorder: enableBorder,
disableBorder: disableBorder,
focusBorder: focusBorder,
onDispose: onDispose,
onFocusChange: onFocusChange,
inputDecoration: inputDecoration
);