flutter TextField 属性分析
flutter InputDecoration
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 InputDecoration.collapsed({
    @required this.hintText,
    this.hasFloatingPlaceholder = true,
    this.hintStyle,
    this.filled = false,
    this.fillColor,
    this.border = InputBorder.none,
    this.enabled = true,
})

flutter TextField 属性分析

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐