TDInput constructor
TDInput({
- Key? key,
- double? width,
- double? height,
- TextStyle? textStyle,
- Color? backgroundColor,
- Decoration? decoration,
- Widget? leftIcon,
- String? leftLabel,
- TextStyle? leftLabelStyle,
- bool? required,
- bool readOnly = false,
- bool autofocus = false,
- bool obscureText = false,
- VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onSubmitted, - String? hintText,
- TextInputType? inputType,
- ValueChanged<
String> ? onChanged, - List<
TextInputFormatter> ? inputFormatters, - InputDecoration? inputDecoration,
- int maxLines = 1,
- FocusNode? focusNode,
- TextEditingController? controller,
- Color? cursorColor,
- Widget? rightBtn,
- TextStyle? hintTextStyle,
- GestureTapCallback? onBtnTap,
- Widget? labelWidget,
- Color? textInputBackgroundColor,
- EdgeInsetsGeometry? contentPadding,
- TDInputType type = TDInputType.normal,
- TDInputSize size = TDInputSize.large,
- double? leftInfoWidth,
- int? maxNum = 500,
- String? additionInfo = '',
- Color? additionInfoColor,
- TextAlign? textAlign,
- GestureTapCallback? onClearTap,
- bool needClear = true,
- Color? clearBtnColor,
- TextAlign contentAlignment = TextAlign.start,
- Widget? rightWidget,
- TDCardStyle? cardStyle,
- String? cardStyleTopText,
- String? cardStyleBottomText,
Implementation
TDInput(
{Key? key,
this.width,
double? height,
this.textStyle,
this.backgroundColor,
this.decoration,
this.leftIcon,// leftIcon is default designed 24 in size.
this.leftLabel,
this.leftLabelStyle,
this.required,
this.readOnly = false,
this.autofocus = false,
this.obscureText = false,
this.onEditingComplete,
this.onSubmitted,
this.hintText,
this.inputType,
this.onChanged,
this.inputFormatters,
this.inputDecoration,
this.maxLines = 1,
this.focusNode,
this.controller,
this.cursorColor,
this.rightBtn,
this.hintTextStyle,
this.onBtnTap,
this.labelWidget,
this.textInputBackgroundColor,
this.contentPadding,
this.type = TDInputType.normal,
this.size = TDInputSize.large,
double? leftInfoWidth,
this.maxNum = 500,
this.additionInfo = '',
this.additionInfoColor,
this.textAlign,
this.onClearTap,
this.needClear = true,
this.clearBtnColor,
this.contentAlignment = TextAlign.start,
this.rightWidget,
this.cardStyle,
this.cardStyleTopText,
this.cardStyleBottomText})
: assert(() {
if (type == TDInputType.cardStyle) {
// card style must be shorter than the screen width, so please set a
// width to show.
assert(width != null);
}
return true;
}()),
// 输入框左侧内容宽度(不包括最左侧的16dp padding)
// leftLabel:左侧'标签文字',一个字宽度16,最多一行展示5个字(5个字时,多一点荣誉)
// leftIcon: 左侧icon,限制大小为24,再加上4dp的间距,即28
// required: 是否必填的'*'标记,占位14(包括间距)
leftInfoWidth = leftInfoWidth ??
((leftLabel == null && leftIcon == null && !(required ?? false))
? 0
: ((leftLabel?.length == null
? 0
: (leftLabel!.length > 5
? 5.1
: leftLabel.length)) *
16 +
(leftIcon != null ? 1 : 0) * 28) +
(required == true ? 1 : 0) * 14),
height = 56,
super(key: key);