TDInput constructor

TDInput({
  1. Key? key,
  2. double? width,
  3. double? height,
  4. TextStyle? textStyle,
  5. Color? backgroundColor,
  6. Decoration? decoration,
  7. Widget? leftIcon,
  8. String? leftLabel,
  9. TextStyle? leftLabelStyle,
  10. bool? required,
  11. bool readOnly = false,
  12. bool autofocus = false,
  13. bool obscureText = false,
  14. VoidCallback? onEditingComplete,
  15. ValueChanged<String>? onSubmitted,
  16. String? hintText,
  17. TextInputType? inputType,
  18. ValueChanged<String>? onChanged,
  19. List<TextInputFormatter>? inputFormatters,
  20. InputDecoration? inputDecoration,
  21. int maxLines = 1,
  22. FocusNode? focusNode,
  23. TextEditingController? controller,
  24. Color? cursorColor,
  25. Widget? rightBtn,
  26. TextStyle? hintTextStyle,
  27. GestureTapCallback? onBtnTap,
  28. Widget? labelWidget,
  29. Color? textInputBackgroundColor,
  30. EdgeInsetsGeometry? contentPadding,
  31. TDInputType type = TDInputType.normal,
  32. TDInputSize size = TDInputSize.large,
  33. double? leftInfoWidth,
  34. int? maxNum = 500,
  35. String? additionInfo = '',
  36. Color? additionInfoColor,
  37. TextAlign? textAlign,
  38. GestureTapCallback? onClearTap,
  39. bool needClear = true,
  40. Color? clearBtnColor,
  41. TextAlign contentAlignment = TextAlign.start,
  42. Widget? rightWidget,
  43. TDCardStyle? cardStyle,
  44. String? cardStyleTopText,
  45. 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);