InputDecoration 源码分析

  1. const InputDecoration({
  2. this.icon, // 装饰器外小图标
  3. this.labelText, // 文本框描述标签
  4. this.labelStyle, // 文本框描述标签样式
  5. this.helperText, // 文本框辅助标签
  6. this.helperStyle, // 文本框辅助标签样式
  7. this.hintText, // 文本框默认提示信息
  8. this.hintStyle, // 文本框默认提示信息样式
  9. this.hintMaxLines, // 文本框默认提示信息最大行数
  10. this.errorText, // 文本框错误提示信息
  11. this.errorStyle, // 文本框错误提示信息样式
  12. this.errorMaxLines, // 文本框错误提示信息最大行数
  13. this.hasFloatingPlaceholder = true, // 文本框获取焦点后 labelText 是否向上浮动
  14. this.isDense, // 是否问紧凑型文本框
  15. this.contentPadding, // 文本内边距
  16. this.prefixIcon, // 前置图标
  17. this.prefix, // 前置预填充 Widget
  18. this.prefixText, // 前置预填充文本
  19. this.prefixStyle, // 前置预填充样式
  20. this.suffixIcon, // 后置图标
  21. this.suffix, // 后置预填充 Widget
  22. this.suffixText, // 后置预填充文本
  23. this.suffixStyle, // 后置预填充样式
  24. this.counter, // 输入框右下角 Widget
  25. this.counterText, // 输入框右下角文本
  26. this.counterStyle, // 输入框右下角样式
  27. this.filled, // 是否颜色填充文本框
  28. this.fillColor, // 填充颜色
  29. this.errorBorder, // errorText 存在时未获取焦点边框
  30. this.focusedBorder, // 获取焦点时边框
  31. this.focusedErrorBorder, // errorText 存在时获取焦点边框
  32. this.disabledBorder, // 不可用时边框
  33. this.enabledBorder, // 可用时边框
  34. this.border, // 边框
  35. this.enabled = true, // 输入框是否可用
  36. this.semanticCounterText,
  37. this.alignLabelWithHint, // 覆盖将标签与 TextField 的中心对齐
  38. })
  39. const ({
  40. @required this.hintText,
  41. this.hasFloatingPlaceholder = true,
  42. this.hintStyle,
  43. this.filled = false,
  44. this.fillColor,
  45. this.border = ,
  46. this.enabled = true,
  47. })

分析源码可知,Flutter 不仅提供了全面的构建装饰器的方式,还提供了简单便利的构建方式 collapsed 默认是无边框的,且无法设置标签等其他属性;

http://www.cainiaoxueyuan.com/xcx/17094.html