InputDecoration 源码分析
const InputDecoration({
this.icon, // 装饰器外小图标
this.labelText, // 文本框描述标签
this.labelStyle, // 文本框描述标签样式
this.helperText, // 文本框辅助标签
this.helperStyle, // 文本框辅助标签样式
this.hintText, // 文本框默认提示信息
this.hintStyle, // 文本框默认提示信息样式
this.hintMaxLines, // 文本框默认提示信息最大行数
this.errorText, // 文本框错误提示信息
this.errorStyle, // 文本框错误提示信息样式
this.errorMaxLines, // 文本框错误提示信息最大行数
this.hasFloatingPlaceholder = true, // 文本框获取焦点后 labelText 是否向上浮动
this.isDense, // 是否问紧凑型文本框
this.contentPadding, // 文本内边距
this.prefixIcon, // 前置图标
this.prefix, // 前置预填充 Widget
this.prefixText, // 前置预填充文本
this.prefixStyle, // 前置预填充样式
this.suffixIcon, // 后置图标
this.suffix, // 后置预填充 Widget
this.suffixText, // 后置预填充文本
this.suffixStyle, // 后置预填充样式
this.counter, // 输入框右下角 Widget
this.counterText, // 输入框右下角文本
this.counterStyle, // 输入框右下角样式
this.filled, // 是否颜色填充文本框
this.fillColor, // 填充颜色
this.errorBorder, // errorText 存在时未获取焦点边框
this.focusedBorder, // 获取焦点时边框
this.focusedErrorBorder, // errorText 存在时获取焦点边框
this.disabledBorder, // 不可用时边框
this.enabledBorder, // 可用时边框
this.border, // 边框
this.enabled = true, // 输入框是否可用
this.semanticCounterText,
this.alignLabelWithHint, // 覆盖将标签与 TextField 的中心对齐
})
const ({
@required this.hintText,
this.hasFloatingPlaceholder = true,
this.hintStyle,
this.filled = false,
this.fillColor,
this.border = ,
this.enabled = true,
})
分析源码可知,Flutter 不仅提供了全面的构建装饰器的方式,还提供了简单便利的构建方式 collapsed 默认是无边框的,且无法设置标签等其他属性;