MInputDecoration class
Constructors
MInputDecoration ({Widget ? icon , Color ? iconColor , Widget ? label , String ? labelText , TextStyle ? labelStyle , TextStyle ? floatingLabelStyle , String ? helperText , TextStyle ? helperStyle , int ? helperMaxLines , String ? hintText , TextStyle ? hintStyle , TextDirection ? hintTextDirection , int ? hintMaxLines , Duration ? hintFadeDuration , Widget ? error , String ? errorText , TextStyle ? errorStyle , int ? errorMaxLines , FloatingLabelBehavior ? floatingLabelBehavior , FloatingLabelAlignment ? floatingLabelAlignment , bool ? isCollapsed , bool ? isDense , EdgeInsetsGeometry ? contentPadding , Widget ? prefixIcon , BoxConstraints ? prefixIconConstraints , Widget ? prefix , String ? prefixText , TextStyle ? prefixStyle , Color ? prefixIconColor , Widget ? suffixIcon , Widget ? suffix , String ? suffixText , TextStyle ? suffixStyle , Color ? suffixIconColor , BoxConstraints ? suffixIconConstraints , Widget ? counter , String ? counterText , TextStyle ? counterStyle , bool ? filled , Color ? fillColor , Color ? focusColor , Color ? hoverColor , InputBorder ? errorBorder , InputBorder ? focusedBorder , InputBorder ? focusedErrorBorder , InputBorder ? disabledBorder , InputBorder ? enabledBorder , InputBorder ? border , bool enabled = true , String ? semanticCounterText , bool ? alignLabelWithHint , BoxConstraints ? constraints , BorderRadius ? borderRadius , MInputBorderStyle borderStyle = MInputBorderStyle.underline , double ? gapPadding , double ? height , Color ? hintColor , double ? radius , BorderSide ? side , EdgeInsetsGeometry ? suffixPadding , EdgeInsetsGeometry ? suffixIconPadding , String ? text , double ? width , bool uniformBorderStyles = false })
const
MInputDecoration.collapsed ({required String ? hintText , FloatingLabelBehavior ? floatingLabelBehavior , FloatingLabelAlignment ? floatingLabelAlignment , TextStyle ? hintStyle , TextDirection ? hintTextDirection , bool ? filled = false , Color ? fillColor , Color ? focusColor , Color ? hoverColor , InputBorder ? border = InputBorder.none , bool enabled = true })
const
Properties
alignLabelWithHint
→ bool ?
Typically set to true when the InputDecorator contains a multiline
TextField (TextField.maxLines is null or > 1) to override the default
behavior of aligning the label with the center of the TextField .
final inherited
border
→ InputBorder ?
The shape of the border to draw around the decoration's container.
final inherited
borderRadius
→ BorderRadius ?
如果 labelText 或者 helperText 存在,则将此标签与它们对齐
输入框的边框, 默认情况下为 UnderlineInputBorder .
如果设置了borderRadius 或 radius 或 side 或 gapPadding , 则根据 borderStyle 重新计算边框
当你使用从 InputBorder 派生的边框时(比如 UnderlineInputBorder 或 OutlineInputBorder ),
Flutter 会自动调整边框的 InputBorder.borderSide 属性,
也就是说,它会根据输入框的状态(比如是否有错误、是否获得焦点等)来调整边框的颜色和宽度。
这意味着,即使你为 border 属性指定了颜色和宽度,这些设置也会被覆盖,以反映输入装饰器的当前状态。
因此,如果你想要为不同的输入状态(错误、聚焦、启用、禁用)保持自定义的边框样式,
你需要单独设置 errorBorder 、focusedBorder 、enabledBorder 和 disabledBorder 属性,而不是仅依赖于 border 属性。
边框圆角, 会统一设置所有状态下的 border , 无视 uniformBorderStyles
但是优先级比单独设置某一状态的 border 低
final
borderStyle
→ MInputBorderStyle
border 样式, 默认 MInputBorderStyle.underline
final
constraints
→ BoxConstraints ?
Defines minimum and maximum sizes for the InputDecorator .
final inherited
contentPadding
→ EdgeInsetsGeometry ?
The padding for the input decoration's container.
final inherited
counter
→ Widget ?
Optional custom counter widget to go in the place otherwise occupied by
counterText . If this property is non null, then counterText is
ignored.
final inherited
counterStyle
→ TextStyle ?
The style to use for the counterText .
final inherited
counterText
→ String ?
Optional text to place below the line as a character count.
final inherited
disabledBorder
→ InputBorder ?
The border to display when the InputDecorator is disabled and is not
showing an error.
final inherited
enabled
→ bool
If false helperText ,errorText , and counterText are not displayed,
and the opacity of the remaining visual elements is reduced.
final inherited
enabledBorder
→ InputBorder ?
The border to display when the InputDecorator is enabled and is not
showing an error.
final inherited
error
→ Widget ?
Optional widget that appears below the InputDecorator.child and the border.
final inherited
errorBorder
→ InputBorder ?
The border to display when the InputDecorator does not have the focus and
is showing an error.
final inherited
errorMaxLines
→ int ?
The maximum number of lines the errorText can occupy.
final inherited
errorStyle
→ TextStyle ?
The style to use for the InputDecoration.errorText .
final inherited
errorText
→ String ?
Text that appears below the InputDecorator.child and the border.
final inherited
fillColor
→ Color ?
The base fill color of the decoration's container color.
final inherited
filled
→ bool ?
If true the decoration's container is filled with fillColor .
final inherited
floatingLabelAlignment
→ FloatingLabelAlignment ?
Defines where the floating label should be displayed.
final inherited
floatingLabelBehavior
→ FloatingLabelBehavior ?
Defines how the floating label should behave.
final inherited
floatingLabelStyle
→ TextStyle ?
The style to use for InputDecoration.labelText when the label is
above (i.e., vertically adjacent to) the input field.
final inherited
focusColor
→ Color ?
The fill color of the decoration's container when it has the input focus.
final inherited
focusedBorder
→ InputBorder ?
The border to display when the InputDecorator has the focus and is not
showing an error.
final inherited
focusedErrorBorder
→ InputBorder ?
The border to display when the InputDecorator has the focus and is
showing an error.
final inherited
gapPadding
→ double ?
输入框的大小约束
内容的内边距
默认情况下,contentPadding 反映 isDense 和 border 的类型。
如果 isCollapsed 为true,那么 contentPadding 就是 EdgeInsets.zero 。
如果 border 的 isOutline
属性为假,且 filled 为真,
则当 isDense 为真时,contentPadding 为 EdgeInsets.fromLTRB(12, 8, 12, 8)
;
当 isDense 为假时,contentPadding 为 EdgeInsets.fromLTRB(12, 12, 12, 12)
。
如果 border 的 isOutline
属性为 false,且 filled 为 false,
则当 isDense 为真时,contentPadding 为 EdgeInsets.fromLTRB(0, 8, 0, 8)
;
当 isDense 为假时,contentPadding 为 EdgeInsets.fromLTRB(0, 12, 0, 12)
。
如果 border 的 isOutline
属性为 true,
则当 isDense 为 true 时,contentPadding 为 EdgeInsets.fromLTRB(12, 20, 12, 12)
;
当 isDense 为 false 时,contentPadding 为 EdgeInsets.fromLTRB(12, 24, 12, 16)
。
如果设置了 suffix 相关属性,则此属性的 EdgeInsetsGeometry.right
将被忽略
计数器
计数器的样式
计数器的文本
禁用状态下的边框
是否启用输入框
启用状态下的边框
错误提示
错误状态下的边框
错误提示的最大行数
错误提示的样式
错误提示的文本
输入框填充的颜色
是否填充输入框
如果为 "true",装饰的容器将被填充为 fillColor 。
默认为 "false", 当 fillColor 不为 null 时默认为 "true".
标签的对齐方式
标签的行为
标签的样式
输入框获取焦点时的颜色
获取焦点时的边框
获取焦点时的错误边框
边框两侧的水平填充, 默认值为 4.0
InputDecoration.labelText 宽度间隙.
final
hashCode
→ int
The hash code for this object.
no setter inherited
height
→ double ?
限定高度, 会限定 MTextField 高度为 height ,
如果想设置初始高度, 在 maxLines
> 1, 并且希望 MTextField 自适应高度的情况下,
推荐设置 isDense 为 true, 配合 contentPadding 来控制初始高度,
注意, suffixIcon 默认约束是 48x48, 如果要设置小于 48 的高度, 需要设置 suffixIconConstraints.minHeight
小于 48.
final
helper
→ Widget ?
Optional widget that appears below the InputDecorator.child .
final inherited
helperMaxLines
→ int ?
The maximum number of lines the helperText can occupy.
final inherited
helperStyle
→ TextStyle ?
The style to use for the helperText .
final inherited
helperText
→ String ?
Text that provides context about the InputDecorator.child 's value, such
as how the value will be used.
final inherited
hintColor
→ Color ?
是否折叠
是否紧凑
标签
标签的样式
标签的文本
提示颜色
final
hintFadeDuration
→ Duration ?
The duration of the hintText fade in and fade out animations.
final inherited
hintMaxLines
→ int ?
The maximum number of lines the hintText can occupy.
final inherited
hintStyle
→ TextStyle ?
The style to use for the hintText .
final inherited
hintText
→ String ?
Text that suggests what sort of input the field accepts.
final inherited
hintTextDirection
→ TextDirection ?
The direction to use for the hintText .
final inherited
hoverColor
→ Color ?
The color of the highlight for the decoration shown if the container
is being hovered over by a mouse.
final inherited
icon
→ Widget ?
An icon to show before the input field and outside of the decoration's
container.
final inherited
iconColor
→ Color ?
The color of the icon .
final inherited
isCollapsed
→ bool ?
Whether the decoration is the same size as the input field.
final inherited
isDense
→ bool ?
Whether the InputDecorator.child is part of a dense form (i.e., uses less vertical
space).
final inherited
label
→ Widget ?
Optional widget that describes the input field.
final inherited
labelStyle
→ TextStyle ?
The style to use for InputDecoration.labelText when the label is on top
of the input field.
final inherited
labelText
→ String ?
Optional text that describes the input field.
final inherited
prefix
→ Widget ?
Optional widget to place on the line before the input.
final inherited
prefixIcon
→ Widget ?
An icon that appears before the prefix or prefixText and before
the editable part of the text field, within the decoration's container.
final inherited
prefixIconColor
→ Color ?
Optional color of the prefixIcon
final inherited
prefixIconConstraints
→ BoxConstraints ?
The constraints for the prefix icon.
final inherited
prefixStyle
→ TextStyle ?
The style to use for the prefixText .
final inherited
prefixText
→ String ?
Optional text prefix to place on the line before the input.
final inherited
radius
→ double ?
帮助提示的最大行数
帮助提示的样式
帮助提示的文本
提示文字淡出动画的持续时间
提示文字的最大行数
提示文字的样式
提示文字的文本
提示文字的方向
鼠标悬浮时的颜色
前缀图标
前缀图标的颜色
前缀
前缀图标
前缀图标的颜色
前缀图标的约束
前缀的样式
前缀的文本
圆角半径, 会统一设置所有状态下的 border , 无视 uniformBorderStyles
但是优先级比单独设置某一状态的 border 低
final
runtimeType
→ Type
A representation of the runtime type of the object.
no setter inherited
semanticCounterText
→ String ?
A semantic label for the counterText .
final inherited
side
→ BorderSide ?
统计信息的文本,用于读屏软件
边框颜色粗细等样式, 会统一设置所有状态下的 border , 无视 uniformBorderStyles
但是优先级比单独设置某一状态的 border 低
final
suffix
→ Widget ?
Optional widget to place on the line after the input.
final inherited
suffixIcon
→ Widget ?
An icon that appears after the editable part of the text field and
after the suffix or suffixText , within the decoration's container.
final inherited
suffixIconColor
→ Color ?
Optional color of the suffixIcon .
final inherited
suffixIconConstraints
→ BoxConstraints ?
The constraints for the suffix icon.
final inherited
suffixIconPadding
→ EdgeInsetsGeometry ?
后缀图标的边距
final
suffixPadding
→ EdgeInsetsGeometry ?
后缀
后缀图标
后缀图标的颜色
后缀图标的约束, 比如限制宽高, 默认是 48x48, 在 InputDecorator 中被设置为 kMinInteractiveDimension
后缀的样式
后缀的文本, 如果和 suffixIcon 一起使用,会显示在图标的前面
后缀的边距
final
suffixStyle
→ TextStyle ?
The style to use for the suffixText .
final inherited
suffixText
→ String ?
Optional text suffix to place on the line after the input.
final inherited
text
→ String ?
默认文本
final
uniformBorderStyles
→ bool
是否使用统一的边框样式
设置为 true, 会强制所有状态下使用同一种边框样式,
优先级 border > enabledBorder > focusedBorder > disabledBorder > errorBorder > focusedErrorBorder ,
如果都为空则使用 InputBorder.none
默认为 false
final
width
→ double ?
固定宽度
final
Methods
applyDefaults (InputDecorationTheme theme )
→ InputDecoration
Used by widgets like TextField and InputDecorator to create a new
InputDecoration with default values taken from the theme
.
inherited
copyWith ({Widget ? icon , Color ? iconColor , Widget ? label , String ? labelText , TextStyle ? labelStyle , TextStyle ? floatingLabelStyle , Widget ? helper , String ? helperText , TextStyle ? helperStyle , int ? helperMaxLines , String ? hintText , TextStyle ? hintStyle , TextDirection ? hintTextDirection , Duration ? hintFadeDuration , int ? hintMaxLines , Widget ? error , String ? errorText , TextStyle ? errorStyle , int ? errorMaxLines , FloatingLabelBehavior ? floatingLabelBehavior , FloatingLabelAlignment ? floatingLabelAlignment , bool ? isCollapsed , bool ? isDense , EdgeInsetsGeometry ? contentPadding , Widget ? prefixIcon , Widget ? prefix , String ? prefixText , BoxConstraints ? prefixIconConstraints , TextStyle ? prefixStyle , Color ? prefixIconColor , Widget ? suffixIcon , Widget ? suffix , String ? suffixText , TextStyle ? suffixStyle , Color ? suffixIconColor , BoxConstraints ? suffixIconConstraints , Widget ? counter , String ? counterText , TextStyle ? counterStyle , bool ? filled , Color ? fillColor , Color ? focusColor , Color ? hoverColor , InputBorder ? errorBorder , InputBorder ? focusedBorder , InputBorder ? focusedErrorBorder , InputBorder ? disabledBorder , InputBorder ? enabledBorder , InputBorder ? border , bool ? enabled , String ? semanticCounterText , bool ? alignLabelWithHint , BoxConstraints ? constraints })
→ InputDecoration
Creates a copy of this input decoration with the given fields replaced
by the new values.
inherited
generate ({TextStyle ? hintTheme , double ? fontSize })
→ InputDecoration
noSuchMethod (Invocation invocation )
→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString ()
→ String
A string representation of this object.
inherited