TextField根本属性const TextField({ Key key, this.controller, // 管制正在编辑文本 this.focusNode, // 获取键盘焦点 this.decoration = const InputDecoration(), // 边框装璜 TextInputType keyboardType, // 键盘类型 this.textInputAction, // 键盘的操作按钮类型 this.textCapitalization = TextCapitalization.none, // 配置大小写键盘 this.style, // 输出文本款式 this.textAlign = TextAlign.start, // 对齐形式 this.textDirection, // 文本方向 this.autofocus = false, // 是否主动对焦 this.obscureText = false, // 是否暗藏内容,例如明码格局 this.autocorrect = true, // 是否主动校对 this.maxLines = 1, // 最大行数 this.maxLength, // 容许输出的最大长度 this.maxLengthEnforced = true, // 是否容许超过输出最大长度 this.onChanged, // 文本内容变更时回调 this.onEditingComplete, // 提交内容时回调 this.onSubmitted, // 用户提醒实现时回调 this.inputFormatters, // 验证及格局 this.enabled, // 是否不可点击 this.cursorWidth = 2.0, // 光标宽度 this.cursorRadius, // 光标圆角弧度 this.cursorColor, // 光标色彩 this.keyboardAppearance, // 键盘亮度 this.scrollPadding = const EdgeInsets.all(20.0), // 滚动到视图中时,填充边距 this.enableInteractiveSelection, // 长按是否展现【剪切/复制/粘贴菜单LengthLimitingTextInputFormatter】 this.onTap, // 点击时回调}) InputDecoration属性详解InputDecoration({ this.icon, //位于装璜器内部和输入框后面的图片 this.labelText, //用于形容输入框,例如这个输入框是用来输出用户名还是明码的,当输入框获取焦点时默认会浮动到上方, this.labelStyle, // 管制labelText的款式,接管一个TextStyle类型的值 this.helperText, //辅助文本,位于输入框下方,如果errorText不为空的话,则helperText不会显示 this.helperStyle, //helperText的款式 this.hintText, //提醒文本,位于输入框外部 this.hintStyle, //hintText的款式 this.hintMaxLines, //提示信息最大行数 this.errorText, //错误信息提醒 this.errorStyle, //errorText的款式 this.errorMaxLines, //errorText最大行数 this.hasFloatingPlaceholder = true, //labelText是否浮动,默认为true,批改为false则labelText在输入框获取焦点时不会浮动且不显示 this.isDense, //扭转输入框是否为密集型,默认为false,批改为true时,图标及间距会变小 this.contentPadding, //内间距 this.prefixIcon, //位于输入框外部起始地位的图标。 this.prefix, //事后填充的Widget,跟prefixText同时只能呈现一个 this.prefixText, //预填充的文本,例如手机号后面事后加上区号等 this.prefixStyle, //prefixText的款式 this.suffixIcon, //位于输入框前面的图片,例如个别输入框前面会有个眼睛,管制输出内容是否明文 this.suffix, //位于输入框尾部的控件,同样的不能和suffixText同时应用 this.suffixText,//位于尾部的填充文字 this.suffixStyle, //suffixText的款式 this.counter,//位于输入框右下方的小控件,不能和counterText同时应用 this.counterText,//位于右下方显示的文本,罕用于显示输出的字符数量 this.counterStyle, //counterText的款式 this.filled, //如果为true,则输出应用fillColor指定的色彩填充 this.fillColor, //相当于输入框的背景色彩 this.errorBorder, //errorText不为空,输入框没有焦点时要显示的边框 this.focusedBorder, //输入框有焦点时的边框,如果errorText不为空的话,该属性有效 this.focusedErrorBorder, //errorText不为空时,输入框有焦点时的边框 this.disabledBorder, //输入框禁用时显示的边框,如果errorText不为空的话,该属性有效 this.enabledBorder, //输入框可用时显示的边框,如果errorText不为空的话,该属性有效 this.border, //失常状况下的border this.enabled = true, //输入框是否可用 this.semanticCounterText, this.alignLabelWithHint, }) Flutter TextField 文本输入框的根本属性及详解