pub struct InputDecoration {Show 60 fields
pub icon: Option<WidgetRef>,
pub icon_color: Option<AnyColor>,
pub label: Option<WidgetRef>,
pub label_text: Option<String>,
pub label_style: Option<AnyTextStyle>,
pub floating_label_style: Option<AnyTextStyle>,
pub label_text_direction: Option<TextDirection>,
pub helper: Option<WidgetRef>,
pub helper_text: Option<String>,
pub helper_style: Option<AnyTextStyle>,
pub helper_max_lines: Option<i32>,
pub hint_text: Option<String>,
pub hint: Option<WidgetRef>,
pub hint_style: Option<AnyTextStyle>,
pub hint_text_direction: Option<TextDirection>,
pub hint_max_lines: Option<i32>,
pub hint_fade_duration: Option<Duration>,
pub maintain_hint_height: bool,
pub maintain_hint_size: bool,
pub maintain_label_size: bool,
pub error: Option<WidgetRef>,
pub error_text: Option<String>,
pub error_style: Option<AnyTextStyle>,
pub error_max_lines: Option<i32>,
pub floating_label_behavior: Option<FloatingLabelBehavior>,
pub floating_label_alignment: Option<FloatingLabelAlignment>,
pub is_dense: Option<bool>,
pub content_padding: Option<EdgeInsetsGeometry>,
pub is_collapsed: Option<bool>,
pub prefix_icon: Option<WidgetRef>,
pub prefix_icon_constraints: Option<BoxConstraints>,
pub prefix: Option<WidgetRef>,
pub prefix_text: Option<String>,
pub prefix_style: Option<AnyTextStyle>,
pub prefix_icon_color: Option<AnyColor>,
pub suffix_icon: Option<WidgetRef>,
pub suffix: Option<WidgetRef>,
pub suffix_text: Option<String>,
pub suffix_style: Option<AnyTextStyle>,
pub suffix_icon_color: Option<AnyColor>,
pub suffix_icon_constraints: Option<BoxConstraints>,
pub counter_text: Option<String>,
pub counter: Option<WidgetRef>,
pub counter_style: Option<AnyTextStyle>,
pub filled: Option<bool>,
pub fill_color: Option<AnyColor>,
pub focus_color: Option<Color>,
pub hover_color: Option<Color>,
pub error_border: Option<InputBorderRef>,
pub focused_border: Option<InputBorderRef>,
pub focused_error_border: Option<InputBorderRef>,
pub disabled_border: Option<InputBorderRef>,
pub enabled_border: Option<InputBorderRef>,
pub border: Option<InputBorderRef>,
pub enabled: bool,
pub semantic_counter_text: Option<String>,
pub align_label_with_hint: Option<bool>,
pub constraints: Option<BoxConstraints>,
pub visual_density: Option<VisualDensity>,
pub supporting_text_padding: Option<EdgeInsetsGeometry>,
}Expand description
The border, labels, icons, and styles used to decorate a Material Design text field.
The TextField and InputDecorator classes use InputDecoration objects
to describe their decoration. (In fact, this class is merely the
configuration of an InputDecorator, which does all the heavy lifting.)
See also:
TextField, which is a text input widget that uses anInputDecoration.InputDecorator, which is a widget that draws anInputDecorationaround an input child widget.DecorationandDecoratedBox, for drawing borders and backgrounds around a child widget.
Dart’s two constructors are new and collapsed, and
their named arguments the fluent setters, which every decoration has. Dart’s constructor
asserts that relate two arguments run in debug_check_arguments, which InputDecorator
calls when it is turned into a WidgetRef (into_widget).
Fields§
§icon: Option<WidgetRef>An icon to show before the input field and outside of the decoration’s container.
The size and color of the icon is configured automatically using an
IconTheme and therefore does not need to be explicitly given in the
icon widget.
The trailing edge of the icon is padded by 16dps.
The decoration’s container is the area which is filled if filled is
true and bordered per the border. It’s the area adjacent to
icon and above the widgets that contain helper_text,
error_text, and counter_text.
See Icon, ImageIcon.
icon_color: Option<AnyColor>The color of the icon.
If icon_color is a WidgetStateColor, then the effective
color can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
label: Option<WidgetRef>Optional widget that describes the input field.
When the input field is empty and unfocused, the label is displayed on
top of the input field (i.e., at the same location on the screen where
text may be entered in the input field). When the input field receives
focus (or if the field is non-empty), depending on floating_label_alignment,
the label moves above, either vertically adjacent to, or to the center of
the input field.
This can be used, for example, to add multiple TextStyle’s to a label that would
otherwise be specified using label_text, which only takes one TextStyle.
Only one of label and label_text can be specified.
label_text: Option<String>Optional text that describes the input field.
When the input field is empty and unfocused, the label is displayed on
top of the input field (i.e., at the same location on the screen where
text may be entered in the input field). When the input field receives
focus (or if the field is non-empty), depending on floating_label_alignment,
the label moves above, either vertically adjacent to, or to the center of
the input field.
If a more elaborate label is required, consider using label instead.
Only one of label and label_text can be specified.
label_style: Option<AnyTextStyle>The style to use for InputDecoration::label_text when the label is on top
of the input field.
If label_style is a WidgetStateTextStyle, then the effective
text style can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
When the InputDecoration::label_text is above (i.e., vertically adjacent to)
the input field, the text uses the floating_label_style instead.
If null, defaults to a value derived from the base TextStyle for the
input field and the current Theme.
Specifying this style will override the default behavior
of InputDecoration that changes the color of the label to the
InputDecoration::error_style color or ColorScheme::error.
floating_label_style: Option<AnyTextStyle>The style to use for InputDecoration::label_text when the label is
above (i.e., vertically adjacent to) the input field.
When the InputDecoration::label_text is on top of the input field, the
text uses the label_style instead.
If floating_label_style is a WidgetStateTextStyle, then the effective
text style can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
If null, defaults to label_style.
Specifying this style will override the default behavior
of InputDecoration that changes the color of the label to the
InputDecoration::error_style color or ColorScheme::error.
When the input field receives focus, the font size of InputDecoration::label is
scaled down by 75%.
label_text_direction: Option<TextDirection>The direction to use for the label_text.
If null, defaults to a value derived from Directionality for the
input field and the current context.
This is ignored if label is provided instead of label_text.
If you need to set the direction for a custom label widget,
wrap that widget in a Directionality widget or use a Text
widget with its own Text::text_direction property.
helper: Option<WidgetRef>Optional widget that appears below the InputDecorator::child.
If non-null, the helper is displayed below the InputDecorator::child, in
the same location as error. If a non-null error or error_text value is
specified then the helper is not shown.
Only one of helper and helper_text can be specified.
helper_text: Option<String>Text that provides context about the InputDecorator::child’s value, such
as how the value will be used.
If non-null, the text is displayed below the InputDecorator::child, in
the same location as error_text. If a non-null error_text value is
specified then the helper text is not shown.
If a more elaborate helper text is required, consider using helper instead.
Only one of helper and helper_text can be specified.
helper_style: Option<AnyTextStyle>The style to use for the helper_text.
If helper_style is a WidgetStateTextStyle, then the effective
text style can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
helper_max_lines: Option<i32>The maximum number of lines the helper_text can occupy.
Defaults to null, which means that soft line breaks in helper_text are
truncated with an ellipse while hard line breaks are respected.
For example, a helper_text that overflows the width of the field will be
truncated with an ellipse. However, a helper_text with explicit linebreak
characters (\n) will display on multiple lines.
To cause a long helper_text to wrap, either set helper_max_lines or use
helper which offers more flexibility. For instance, it can be set to a
Text widget with a specific overflow value.
This value is passed along to the Text::max_lines attribute
of the Text widget used to display the helper.
See also:
error_max_lines, the equivalent but for theerror_text.
hint_text: Option<String>Text that suggests what sort of input the field accepts.
Displayed on top of the InputDecorator::child (i.e., at the same location
on the screen where text may be entered in the InputDecorator::child),
when InputDecorator::is_empty is true and either (a) label_text is null
or (b) the input has the focus.
hint: Option<WidgetRef>The widget to use in place of the hint_text.
Either hint_text or hint can be specified, but not both.
hint_style: Option<AnyTextStyle>The style to use for the hint_text.
If hint_style is a WidgetStateTextStyle, then the effective
text style can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
Also used for the label_text when the label_text is displayed on
top of the input field (i.e., at the same location on the screen where
text may be entered in the InputDecorator::child).
If null, defaults to a value derived from the base TextStyle for the
input field and the current Theme.
hint_text_direction: Option<TextDirection>The direction to use for the hint_text.
If null, defaults to a value derived from Directionality for the
input field and the current context.
This is ignored if hint is provided instead of hint_text.
If you need to set the direction for a custom hint widget,
wrap that widget in a Directionality widget or use a Text
widget with its own Text::text_direction property.
hint_max_lines: Option<i32>The maximum number of lines the hint_text can occupy.
Defaults to the value of TextField::max_lines attribute.
This value is passed along to the Text::max_lines attribute
of the Text widget used to display the hint text. TextOverflow::Ellipsis is
used to handle the overflow when it is limited to single line.
hint_fade_duration: Option<Duration>The duration of the hint_text fade in and fade out animations.
If null, defaults to InputDecorationThemeData::hint_fade_duration.
If InputDecorationThemeData::hint_fade_duration is null defaults to 20ms.
maintain_hint_height: boolUse maintainHintSize instead. This will maintain both hint height and hint width. This feature was deprecated after v3.28.0-2.0.pre.
Whether the input field’s height should always be greater than or equal to
the height of the hint_text, even if the hint_text is not visible.
The InputDecorator widget ignores hint_text during layout when
it’s not visible, if this flag is set to false.
Defaults to true.
maintain_hint_size: boolWhether the input field’s size should always be greater than or equal to
the size of the hint or hint_text, even if the hint or hint_text are not visible.
The InputDecorator widget ignores hint and hint_text during layout when
they are not visible, if this flag is set to false.
Defaults to true.
maintain_label_size: boolWhether the input field’s size should always be greater than or equal to
the size of the label or label_text, even if the label or label_text are not visible.
The InputDecorator widget ignores label and label_text during layout when
this flag is set to false.
Defaults to false for compatibility reason.
error: Option<WidgetRef>Optional widget that appears below the InputDecorator::child and the border.
If non-null, the border’s color animates to red and the helper_text is not shown.
Only one of error and error_text can be specified.
error_text: Option<String>Text that appears below the InputDecorator::child and the border.
If non-null, the border’s color animates to red and the helper_text is
not shown.
In a TextFormField, this is overridden by the value returned from
TextFormField::validator, if that is not null.
If a more elaborate error is required, consider using error instead.
Only one of error and error_text can be specified.
error_style: Option<AnyTextStyle>The style to use for the InputDecoration::error_text.
If null, defaults of a value derived from the base TextStyle for the
input field and the current Theme.
By default the color of style will be used by the label of
InputDecoration if InputDecoration::error_text is not null. See
InputDecoration::label_style or InputDecoration::floating_label_style for
an example of how to replicate this behavior when specifying those
styles.
error_max_lines: Option<i32>The maximum number of lines the error_text can occupy.
Defaults to null, which means that soft line breaks in error_text are
truncated with an ellipse while hard line breaks are respected.
For example, an error_text that overflows the width of the field will be
truncated with an ellipse. However, an error_text with explicit linebreak
characters (\n) will display on multiple lines.
To cause a long error_text to wrap, either set error_max_lines or use
error which offers more flexibility. For instance, it can be set to a
Text widget with a specific overflow value.
This value is passed along to the Text::max_lines attribute
of the Text widget used to display the error.
See also:
helper_max_lines, the equivalent but for thehelper_text.
floating_label_behavior: Option<FloatingLabelBehavior>Defines how the floating label should behave.
When FloatingLabelBehavior::Auto the label will float to the top only when
the field is focused or has some text content, otherwise it will appear
in the field in place of the content.
When FloatingLabelBehavior::Always the label will always float at the top
of the field above the content.
When FloatingLabelBehavior::Never the label will always appear in an empty
field in place of the content.
If null, InputDecorationThemeData::floating_label_behavior will be used.
See also:
floating_label_alignmentwhich defines where the floating label should be displayed.
floating_label_alignment: Option<FloatingLabelAlignment>Defines where the floating label should be displayed.
FloatingLabelAlignment::START aligns the floating label to the leftmost
(when TextDirection::Ltr) or rightmost (when TextDirection::Rtl),
possible position, which is vertically adjacent to the label, on top of
the field.
FloatingLabelAlignment::CENTER aligns the floating label to the center on
top of the field.
If null, InputDecorationThemeData::floating_label_alignment will be used.
See also:
floating_label_behaviorwhich defines how the floating label should behave.
is_dense: Option<bool>Whether the InputDecorator::child is part of a dense form (i.e., uses less vertical
space).
Defaults to false.
content_padding: Option<EdgeInsetsGeometry>The padding for the input decoration’s container.
The decoration’s container is the area which is filled if filled is true
and bordered per the border. It’s the area adjacent to icon and above
the widgets that contain helper_text, error_text, and counter_text.
By default the content_padding reflects is_dense and the type of the
border.
If is_collapsed is true then content_padding is EdgeInsets::ZERO.
§Material 3 default content padding
If isOutline property of border is false and if filled is true then
content_padding is EdgeInsets.fromLTRB(12, 4, 12, 4) when is_dense
is true and EdgeInsets.fromLTRB(12, 8, 12, 8) when is_dense is false.
If isOutline property of border is false and if filled is false then
content_padding is EdgeInsets.fromLTRB(0, 4, 0, 4) when is_dense is
true and EdgeInsets.fromLTRB(0, 8, 0, 8) when is_dense is false.
If isOutline property of border is true then content_padding is
EdgeInsets.fromLTRB(12, 16, 12, 8) when is_dense is true
and EdgeInsets.fromLTRB(12, 20, 12, 12) when is_dense is false.
§Material 2 default content padding
If isOutline property of border is false and if filled is true then
content_padding is EdgeInsets.fromLTRB(12, 8, 12, 8) when is_dense
is true and EdgeInsets.fromLTRB(12, 12, 12, 12) when is_dense is false.
If isOutline property of border is false and if filled is false then
content_padding is EdgeInsets.fromLTRB(0, 8, 0, 8) when is_dense is
true and EdgeInsets.fromLTRB(0, 12, 0, 12) when is_dense is false.
If isOutline property of border is true then content_padding is
EdgeInsets.fromLTRB(12, 20, 12, 12) when is_dense is true
and EdgeInsets.fromLTRB(12, 24, 12, 16) when is_dense is false.
is_collapsed: Option<bool>Whether the decoration is the same size as the input field.
A collapsed decoration cannot have label_text, error_text, counter,
icon, prefixes, and suffixes.
To create a collapsed input decoration, use InputDecoration::collapsed.
prefix_icon: Option<WidgetRef>An icon that appears before the prefix or prefix_text and before
the editable part of the text field, within the decoration’s container.
The size and color of the prefix icon is configured automatically using an
IconTheme and therefore does not need to be explicitly given in the
icon widget.
The prefix icon is constrained with a minimum size of 48px by 48px, but can be expanded beyond that. Anything larger than 24px will require additional padding to ensure it matches the Material Design spec of 12px padding between the left edge of the input and leading edge of the prefix icon. The following snippet shows how to pad the leading edge of the prefix icon:
prefixIcon: Padding(
padding: const EdgeInsetsDirectional.only(start: 12.0),
child: _myIcon, // _myIcon is a 48px-wide widget.
)The decoration’s container is the area which is filled if filled is true
and bordered per the border. It’s the area adjacent to icon and above
the widgets that contain helper_text, error_text, and counter_text.
The prefix icon alignment can be changed using Align with a fixed widthFactor and
heightFactor.
See also:
IconandImageIcon, which are typically used to show icons.prefixandprefix_text, which are other ways to show content before the text field (but after the icon).suffix_icon, which is the same but on the trailing edge.AlignA widget that aligns its child within itself and optionally sizes itself based on the child’s size.
prefix_icon_constraints: Option<BoxConstraints>The constraints for the prefix icon.
This can be used to modify the BoxConstraints surrounding prefix_icon.
This property is particularly useful for getting the decoration’s height
less than the minimum tappable height (which is 48px when the visual
density is set to VisualDensity::standard). This can be achieved by
setting is_dense to true and setting the constraints’ minimum height
and width to a value lower than the minimum tappable size.
prefix: Option<WidgetRef>Optional widget to place on the line before the input.
This can be used, for example, to add some padding to text that would
otherwise be specified using prefix_text, or to add a custom widget in
front of the input. The widget’s baseline is lined up with the input
baseline.
Only one of prefix and prefix_text can be specified.
The prefix appears after the prefix_icon, if both are specified.
See also:
suffix, the equivalent but on the trailing edge.
prefix_text: Option<String>Optional text prefix to place on the line before the input.
Uses the prefix_style. Uses hint_style if prefix_style isn’t specified.
The prefix text is not returned as part of the user’s input.
If a more elaborate prefix is required, consider using prefix instead.
Only one of prefix and prefix_text can be specified.
The prefix_text appears after the prefix_icon, if both are specified.
See also:
suffix_text, the equivalent but on the trailing edge.
prefix_style: Option<AnyTextStyle>The style to use for the prefix_text.
If prefix_style is a WidgetStateTextStyle, then the effective
text style can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
If null, defaults to the hint_style.
See also:
suffix_style, the equivalent but on the trailing edge.
prefix_icon_color: Option<AnyColor>Optional color of the prefixIcon
Defaults to icon_color
If prefix_icon_color is a WidgetStateColor, then the effective
color can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
suffix_icon: Option<WidgetRef>An icon that appears after the editable part of the text field and
after the suffix or suffix_text, within the decoration’s container.
The size and color of the suffix icon is configured automatically using an
IconTheme and therefore does not need to be explicitly given in the
icon widget.
The suffix icon is constrained with a minimum size of 48px by 48px, but can be expanded beyond that. Anything larger than 24px will require additional padding to ensure it matches the Material Design spec of 12px padding between the right edge of the input and trailing edge of the prefix icon. The following snippet shows how to pad the trailing edge of the suffix icon:
suffixIcon: Padding(
padding: const EdgeInsetsDirectional.only(end: 12.0),
child: _myIcon, // myIcon is a 48px-wide widget.
)The decoration’s container is the area which is filled if filled is
true and bordered per the border. It’s the area adjacent to
icon and above the widgets that contain helper_text,
error_text, and counter_text.
The suffix icon alignment can be changed using Align with a fixed widthFactor and
heightFactor.
See also:
IconandImageIcon, which are typically used to show icons.suffixandsuffix_text, which are other ways to show content after the text field (but before the icon).prefix_icon, which is the same but on the leading edge.AlignA widget that aligns its child within itself and optionally sizes itself based on the child’s size.
suffix: Option<WidgetRef>Optional widget to place on the line after the input.
This can be used, for example, to add some padding to the text that would
otherwise be specified using suffix_text, or to add a custom widget after
the input. The widget’s baseline is lined up with the input baseline.
Only one of suffix and suffix_text can be specified.
The suffix appears before the suffix_icon, if both are specified.
See also:
prefix, the equivalent but on the leading edge.
suffix_text: Option<String>Optional text suffix to place on the line after the input.
Uses the suffix_style. Uses hint_style if suffix_style isn’t specified.
The suffix text is not returned as part of the user’s input.
If a more elaborate suffix is required, consider using suffix instead.
Only one of suffix and suffix_text can be specified.
The suffix_text appears before the suffix_icon, if both are specified.
See also:
prefix_text, the equivalent but on the leading edge.
suffix_style: Option<AnyTextStyle>The style to use for the suffix_text.
If suffix_style is a WidgetStateTextStyle, then the effective text
style can depend on the WidgetState::Focused state, i.e. if the
TextField is focused or not.
If null, defaults to the hint_style.
See also:
prefix_style, the equivalent but on the leading edge.
suffix_icon_color: Option<AnyColor>Optional color of the suffix_icon.
Defaults to icon_color
If suffix_icon_color is a WidgetStateColor, then the effective
color can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
suffix_icon_constraints: Option<BoxConstraints>The constraints for the suffix icon.
This can be used to modify the BoxConstraints surrounding suffix_icon.
This property is particularly useful for getting the decoration’s height
less than the minimum tappable height (which is 48px when the visual
density is set to VisualDensity::standard). This can be achieved by
setting is_dense to true and setting the constraints’ minimum height
and width to a value lower than the minimum tappable size.
If null, a BoxConstraints with a minimum width and height of 48px is
used.
counter_text: Option<String>Optional text to place below the line as a character count.
Rendered using counter_style. Uses helper_style if counter_style is
null.
The semantic label can be replaced by providing a semantic_counter_text.
If null or an empty string and counter isn’t specified, then nothing
will appear in the counter’s location.
counter: Option<WidgetRef>Optional custom counter widget to go in the place otherwise occupied by
counter_text. If this property is non null, then counter_text is
ignored.
counter_style: Option<AnyTextStyle>The style to use for the counter_text.
If counter_style is a WidgetStateTextStyle, then the effective
text style can depend on the WidgetState::Focused state, i.e.
if the TextField is focused or not.
If null, defaults to the helper_style.
filled: Option<bool>If true the decoration’s container is filled with fill_color.
When InputDecorator::is_hovering is true, the hover_color is also blended
into the final fill color.
Typically this field set to true if border is an UnderlineInputBorder.
The decoration’s container is the area which is filled if filled is true
and bordered per the border. It’s the area adjacent to icon and above
the widgets that contain helper_text, error_text, and counter_text.
This property is false by default.
fill_color: Option<AnyColor>The base fill color of the decoration’s container color.
When InputDecorator::is_hovering is true, the hover_color is also blended
into the final fill color.
By default the fill_color is based on the current
InputDecorationThemeData::fill_color.
The decoration’s container is the area which is filled if filled is true
and bordered per the border. It’s the area adjacent to icon and above
the widgets that contain helper_text, error_text, and counter_text.
focus_color: Option<Color>The fill color of the decoration’s container when it has the input focus.
By default the focus_color is based on the current
InputDecorationThemeData::focus_color.
This focus_color is ignored by TextField and TextFormField because
they don’t respond to focus changes by changing their decorator’s
container color, they respond by changing their border to the
focused_border, which you can change the color of.
The decoration’s container is the area which is filled if filled is true
and bordered per the border. It’s the area adjacent to icon and above
the widgets that contain helper_text, error_text, and counter_text.
hover_color: Option<Color>The color of the highlight for the decoration shown if the container is being hovered over by a mouse.
If filled is true, the hover_color is blended with fill_color and
fills the decoration’s container.
If filled is false, and InputDecorator::is_focused is false, the color
is blended over the enabled_border’s color.
By default the hover_color is based on the current Theme.
The decoration’s container is the area which is filled if filled is true
and bordered per the border. It’s the area adjacent to icon and above
the widgets that contain helper_text, error_text, and counter_text.
error_border: Option<InputBorderRef>The border to display when the InputDecorator does not have the focus and
is showing an error.
See also:
InputDecorator::is_focused, which is true if theInputDecorator’s child has the focus.InputDecoration::error_text, the error shown by theInputDecorator, if non-null.border, for a description of where theInputDecoratorborder appears.UnderlineInputBorder, anInputDecoratorborder which draws a horizontal line at the bottom of the input decorator’s container.OutlineInputBorder, anInputDecoratorborder which draws a rounded rectangle around the input decorator’s container.InputBorderRef::none(), which doesn’t draw a border.focused_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis null.focused_error_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis non-null.disabled_border, displayed whenInputDecoration::enabledis false andInputDecoration::error_textis null.enabled_border, displayed whenInputDecoration::enabledis true andInputDecoration::error_textis null.
focused_border: Option<InputBorderRef>The border to display when the InputDecorator has the focus and is not
showing an error.
See also:
InputDecorator::is_focused, which is true if theInputDecorator’s child has the focus.InputDecoration::error_text, the error shown by theInputDecorator, if non-null.border, for a description of where theInputDecoratorborder appears.UnderlineInputBorder, anInputDecoratorborder which draws a horizontal line at the bottom of the input decorator’s container.OutlineInputBorder, anInputDecoratorborder which draws a rounded rectangle around the input decorator’s container.InputBorderRef::none(), which doesn’t draw a border.error_border, displayed whenInputDecorator::is_focusedis false andInputDecoration::error_textis non-null.focused_error_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis non-null.disabled_border, displayed whenInputDecoration::enabledis false andInputDecoration::error_textis null.enabled_border, displayed whenInputDecoration::enabledis true andInputDecoration::error_textis null.
focused_error_border: Option<InputBorderRef>The border to display when the InputDecorator has the focus and is
showing an error.
See also:
InputDecorator::is_focused, which is true if theInputDecorator’s child has the focus.InputDecoration::error_text, the error shown by theInputDecorator, if non-null.border, for a description of where theInputDecoratorborder appears.UnderlineInputBorder, anInputDecoratorborder which draws a horizontal line at the bottom of the input decorator’s container.OutlineInputBorder, anInputDecoratorborder which draws a rounded rectangle around the input decorator’s container.InputBorderRef::none(), which doesn’t draw a border.error_border, displayed whenInputDecorator::is_focusedis false andInputDecoration::error_textis non-null.focused_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis null.disabled_border, displayed whenInputDecoration::enabledis false andInputDecoration::error_textis null.enabled_border, displayed whenInputDecoration::enabledis true andInputDecoration::error_textis null.
disabled_border: Option<InputBorderRef>The border to display when the InputDecorator is disabled and is not
showing an error.
See also:
InputDecoration::enabled, which is false if theInputDecoratoris disabled.InputDecoration::error_text, the error shown by theInputDecorator, if non-null.border, for a description of where theInputDecoratorborder appears.UnderlineInputBorder, anInputDecoratorborder which draws a horizontal line at the bottom of the input decorator’s container.OutlineInputBorder, anInputDecoratorborder which draws a rounded rectangle around the input decorator’s container.InputBorderRef::none(), which doesn’t draw a border.error_border, displayed whenInputDecorator::is_focusedis false andInputDecoration::error_textis non-null.focused_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis null.focused_error_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis non-null.enabled_border, displayed whenInputDecoration::enabledis true andInputDecoration::error_textis null.
enabled_border: Option<InputBorderRef>The border to display when the InputDecorator is enabled and is not
showing an error.
See also:
InputDecoration::enabled, which is false if theInputDecoratoris disabled.InputDecoration::error_text, the error shown by theInputDecorator, if non-null.border, for a description of where theInputDecoratorborder appears.UnderlineInputBorder, anInputDecoratorborder which draws a horizontal line at the bottom of the input decorator’s container.OutlineInputBorder, anInputDecoratorborder which draws a rounded rectangle around the input decorator’s container.InputBorderRef::none(), which doesn’t draw a border.error_border, displayed whenInputDecorator::is_focusedis false andInputDecoration::error_textis non-null.focused_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis null.focused_error_border, displayed whenInputDecorator::is_focusedis true andInputDecoration::error_textis non-null.disabled_border, displayed whenInputDecoration::enabledis false andInputDecoration::error_textis null.
border: Option<InputBorderRef>The shape of the border to draw around the decoration’s container.
If border is a WidgetStateInputBorder then the effective border is resolved
in the following states:
WidgetState::Disabled.WidgetState::Error.WidgetState::Focused.WidgetState::Hovered.
If border derives from InputBorder the border’s InputBorder::border_side,
i.e. the border’s color and width, will be overridden to reflect the input
decorator’s state. Only the border’s shape is used. If custom BorderSide
values are desired for a given state, all five borders – error_border,
focused_border, enabled_border, disabled_border, focused_error_border – must be set.
The decoration’s container is the area which is filled if filled is
true and bordered per the border. It’s the area adjacent to
InputDecoration::icon and above the widgets that contain
InputDecoration::helper_text, InputDecoration::error_text, and
InputDecoration::counter_text.
The border’s bounds, i.e. the value of border.getOuterPath(), define
the area to be filled.
This property is only used when the appropriate one of error_border,
focused_border, focused_error_border, disabled_border, or enabled_border
is not specified. This border’s InputBorder::border_side property is
configured by the InputDecorator, depending on the values of
InputDecoration::error_text, InputDecoration::enabled,
InputDecorator::is_focused and the current Theme.
Typically one of UnderlineInputBorder or OutlineInputBorder.
If null, InputDecorator’s default is const UnderlineInputBorder().
See also:
InputBorderRef::none(), which doesn’t draw a border.UnderlineInputBorder, which draws a horizontal line at the bottom of the input decorator’s container.OutlineInputBorder, anInputDecoratorborder which draws a rounded rectangle around the input decorator’s container.
enabled: boolIf false the opacity of the visual elements is reduced, including helper_text,error_text, and counter_text.
This property is true by default.
semantic_counter_text: Option<String>A semantic label for the counter_text.
Defaults to null.
If provided, this replaces the semantic label of the counter_text.
align_label_with_hint: Option<bool>Typically set to true when the InputDecorator contains a multiline
TextField (TextField::max_lines is null or > 1) to override the default
behavior of aligning the label with the center of the TextField.
Defaults to false.
constraints: Option<BoxConstraints>Defines minimum and maximum sizes for the InputDecorator.
Typically the decorator will fill the horizontal space it is given. For larger screens, it may be useful to have the maximum width clamped to a given value so it doesn’t fill the whole screen. This property allows you to control how big the decorator will be in its available space.
If null, then the ambient InputDecorationThemeData::constraints will be used.
If that is null then the decorator will fill the available width with
a default height based on text size.
visual_density: Option<VisualDensity>Defines how compact the decoration’s layout will be.
The vertical aspect of the default or user-specified content_padding is adjusted
automatically based on visual_density.
When the visual density is VisualDensity::compact, the vertical aspect of
content_padding is reduced by 8 pixels.
When the visual density is VisualDensity::comfortable, the vertical aspect of
content_padding is reduced by 4 pixels.
When the visual density is VisualDensity::standard vertical aspect of
content_padding is not changed.
If null, then the ambient InputDecorationThemeData::visual_density will be used.
If that is null then ThemeData::visual_density will be used.
See also:
ThemeData::visual_density, which specifies thevisual_densityfor all widgets within aTheme.InputDecorationThemeData::visual_density, which can override this setting for a given decorator.
supporting_text_padding: Option<EdgeInsetsGeometry>The padding around the supporting text row, which contains the helper text, the error text, and the counter.
The start and end values set the horizontal position of the row, the
same way InputDecoration::content_padding does for the input. The top
value is the gap between the bottom of the decoration’s container and
the row, and the bottom value is the space below the row.
If null, the row uses these defaults:
- start and end: the start and end values of
InputDecoration::content_padding. - top: 4.0 for Material 3, 8.0 for Material 2.
- bottom: 0.0.
If non-null, every side of this value is used as is, including sides
that are zero. For example, EdgeInsetsDirectional.only(start: 24.0)
sets the top gap to zero, so the supporting text sits directly against
the container. To change the horizontal padding while keeping the
default Material 3 gap, set the top value explicitly:
const InputDecoration(
helperText: 'Helper text',
supportingTextPadding: EdgeInsetsDirectional.fromSTEB(24.0, 4.0, 24.0, 0.0),
)If both this and InputDecorationThemeData::supporting_text_padding are
non-null, this value replaces the theme value entirely. The two are not
merged side by side.
Implementations§
Source§impl InputDecoration
impl InputDecoration
Sourcepub fn new() -> InputDecoration
pub fn new() -> InputDecoration
Creates a bundle of the border, labels, icons, and styles used to decorate a Material Design text field.
Unless specified by the ambient InputDecorationThemeData, InputDecorator
defaults is_dense to false and filled to false. The default border is
an instance of UnderlineInputBorder. If border is InputBorderRef::none()
then no border is drawn.
Only one of prefix and prefix_text can be specified.
Similarly, only one of suffix and suffix_text can be specified.
Sourcepub fn collapsed(hint_text: Option<String>) -> InputDecoration
pub fn collapsed(hint_text: Option<String>) -> InputDecoration
Defines an InputDecorator that is the same size as the input field.
This type of input decoration does not include a border by default.
A collapsed decoration cannot have label_text, error_text, counter,
icon, prefixes, and suffixes.
Sets the is_collapsed property to true.
Sets the content_padding property to EdgeInsets::ZERO.
Sourcepub fn icon<K>(self, icon: impl IntoWidget<K>) -> InputDecoration
pub fn icon<K>(self, icon: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(icon:).
Sourcepub fn icon_color(self, icon_color: impl Into<AnyColor>) -> InputDecoration
pub fn icon_color(self, icon_color: impl Into<AnyColor>) -> InputDecoration
Dart InputDecoration(iconColor:).
Sourcepub fn label<K>(self, label: impl IntoWidget<K>) -> InputDecoration
pub fn label<K>(self, label: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(label:).
Sourcepub fn label_text(self, label_text: impl Into<String>) -> InputDecoration
pub fn label_text(self, label_text: impl Into<String>) -> InputDecoration
Dart InputDecoration(labelText:).
Sourcepub fn label_style(
self,
label_style: impl Into<AnyTextStyle>,
) -> InputDecoration
pub fn label_style( self, label_style: impl Into<AnyTextStyle>, ) -> InputDecoration
Dart InputDecoration(labelStyle:).
Sourcepub fn floating_label_style(
self,
floating_label_style: impl Into<AnyTextStyle>,
) -> InputDecoration
pub fn floating_label_style( self, floating_label_style: impl Into<AnyTextStyle>, ) -> InputDecoration
Dart InputDecoration(floatingLabelStyle:).
Sourcepub fn label_text_direction(
self,
label_text_direction: TextDirection,
) -> InputDecoration
pub fn label_text_direction( self, label_text_direction: TextDirection, ) -> InputDecoration
Dart InputDecoration(labelTextDirection:).
Sourcepub fn helper<K>(self, helper: impl IntoWidget<K>) -> InputDecoration
pub fn helper<K>(self, helper: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(helper:).
Sourcepub fn helper_text(self, helper_text: impl Into<String>) -> InputDecoration
pub fn helper_text(self, helper_text: impl Into<String>) -> InputDecoration
Dart InputDecoration(helperText:).
Sourcepub fn helper_style(
self,
helper_style: impl Into<AnyTextStyle>,
) -> InputDecoration
pub fn helper_style( self, helper_style: impl Into<AnyTextStyle>, ) -> InputDecoration
Dart InputDecoration(helperStyle:).
Sourcepub fn helper_max_lines(self, helper_max_lines: i32) -> InputDecoration
pub fn helper_max_lines(self, helper_max_lines: i32) -> InputDecoration
Dart InputDecoration(helperMaxLines:).
Sourcepub fn hint_text(self, hint_text: impl Into<String>) -> InputDecoration
pub fn hint_text(self, hint_text: impl Into<String>) -> InputDecoration
Dart InputDecoration(hintText:).
Sourcepub fn hint<K>(self, hint: impl IntoWidget<K>) -> InputDecoration
pub fn hint<K>(self, hint: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(hint:).
Sourcepub fn hint_style(self, hint_style: impl Into<AnyTextStyle>) -> InputDecoration
pub fn hint_style(self, hint_style: impl Into<AnyTextStyle>) -> InputDecoration
Dart InputDecoration(hintStyle:).
Sourcepub fn hint_text_direction(
self,
hint_text_direction: TextDirection,
) -> InputDecoration
pub fn hint_text_direction( self, hint_text_direction: TextDirection, ) -> InputDecoration
Dart InputDecoration(hintTextDirection:).
Sourcepub fn hint_max_lines(self, hint_max_lines: i32) -> InputDecoration
pub fn hint_max_lines(self, hint_max_lines: i32) -> InputDecoration
Dart InputDecoration(hintMaxLines:).
Sourcepub fn hint_fade_duration(self, hint_fade_duration: Duration) -> InputDecoration
pub fn hint_fade_duration(self, hint_fade_duration: Duration) -> InputDecoration
Dart InputDecoration(hintFadeDuration:).
Sourcepub fn maintain_hint_height(self, maintain_hint_height: bool) -> InputDecoration
👎Deprecated: Use maintainHintSize instead. This will maintain both hint height and hint width. This feature was deprecated after v3.28.0-2.0.pre.
pub fn maintain_hint_height(self, maintain_hint_height: bool) -> InputDecoration
Use maintainHintSize instead. This will maintain both hint height and hint width. This feature was deprecated after v3.28.0-2.0.pre.
Dart InputDecoration(maintainHintHeight:).
Sourcepub fn maintain_hint_size(self, maintain_hint_size: bool) -> InputDecoration
pub fn maintain_hint_size(self, maintain_hint_size: bool) -> InputDecoration
Dart InputDecoration(maintainHintSize:).
Sourcepub fn maintain_label_size(self, maintain_label_size: bool) -> InputDecoration
pub fn maintain_label_size(self, maintain_label_size: bool) -> InputDecoration
Dart InputDecoration(maintainLabelSize:).
Sourcepub fn error<K>(self, error: impl IntoWidget<K>) -> InputDecoration
pub fn error<K>(self, error: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(error:).
Sourcepub fn error_text(self, error_text: impl Into<String>) -> InputDecoration
pub fn error_text(self, error_text: impl Into<String>) -> InputDecoration
Dart InputDecoration(errorText:).
Sourcepub fn error_style(
self,
error_style: impl Into<AnyTextStyle>,
) -> InputDecoration
pub fn error_style( self, error_style: impl Into<AnyTextStyle>, ) -> InputDecoration
Dart InputDecoration(errorStyle:).
Sourcepub fn error_max_lines(self, error_max_lines: i32) -> InputDecoration
pub fn error_max_lines(self, error_max_lines: i32) -> InputDecoration
Dart InputDecoration(errorMaxLines:).
Sourcepub fn floating_label_behavior(
self,
floating_label_behavior: FloatingLabelBehavior,
) -> InputDecoration
pub fn floating_label_behavior( self, floating_label_behavior: FloatingLabelBehavior, ) -> InputDecoration
Dart InputDecoration(floatingLabelBehavior:).
Sourcepub fn floating_label_alignment(
self,
floating_label_alignment: FloatingLabelAlignment,
) -> InputDecoration
pub fn floating_label_alignment( self, floating_label_alignment: FloatingLabelAlignment, ) -> InputDecoration
Dart InputDecoration(floatingLabelAlignment:).
Sourcepub fn is_collapsed(self, is_collapsed: bool) -> InputDecoration
pub fn is_collapsed(self, is_collapsed: bool) -> InputDecoration
Dart InputDecoration(isCollapsed:).
Sourcepub fn is_dense(self, is_dense: bool) -> InputDecoration
pub fn is_dense(self, is_dense: bool) -> InputDecoration
Dart InputDecoration(isDense:).
Sourcepub fn content_padding(
self,
content_padding: impl Into<EdgeInsetsGeometry>,
) -> InputDecoration
pub fn content_padding( self, content_padding: impl Into<EdgeInsetsGeometry>, ) -> InputDecoration
Dart InputDecoration(contentPadding:).
Sourcepub fn prefix_icon<K>(self, prefix_icon: impl IntoWidget<K>) -> InputDecoration
pub fn prefix_icon<K>(self, prefix_icon: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(prefixIcon:).
Sourcepub fn prefix_icon_constraints(
self,
prefix_icon_constraints: BoxConstraints,
) -> InputDecoration
pub fn prefix_icon_constraints( self, prefix_icon_constraints: BoxConstraints, ) -> InputDecoration
Dart InputDecoration(prefixIconConstraints:).
Sourcepub fn prefix<K>(self, prefix: impl IntoWidget<K>) -> InputDecoration
pub fn prefix<K>(self, prefix: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(prefix:).
Sourcepub fn prefix_text(self, prefix_text: impl Into<String>) -> InputDecoration
pub fn prefix_text(self, prefix_text: impl Into<String>) -> InputDecoration
Dart InputDecoration(prefixText:).
Sourcepub fn prefix_style(
self,
prefix_style: impl Into<AnyTextStyle>,
) -> InputDecoration
pub fn prefix_style( self, prefix_style: impl Into<AnyTextStyle>, ) -> InputDecoration
Dart InputDecoration(prefixStyle:).
Sourcepub fn prefix_icon_color(
self,
prefix_icon_color: impl Into<AnyColor>,
) -> InputDecoration
pub fn prefix_icon_color( self, prefix_icon_color: impl Into<AnyColor>, ) -> InputDecoration
Dart InputDecoration(prefixIconColor:).
Sourcepub fn suffix_icon<K>(self, suffix_icon: impl IntoWidget<K>) -> InputDecoration
pub fn suffix_icon<K>(self, suffix_icon: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(suffixIcon:).
Sourcepub fn suffix<K>(self, suffix: impl IntoWidget<K>) -> InputDecoration
pub fn suffix<K>(self, suffix: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(suffix:).
Sourcepub fn suffix_text(self, suffix_text: impl Into<String>) -> InputDecoration
pub fn suffix_text(self, suffix_text: impl Into<String>) -> InputDecoration
Dart InputDecoration(suffixText:).
Sourcepub fn suffix_style(
self,
suffix_style: impl Into<AnyTextStyle>,
) -> InputDecoration
pub fn suffix_style( self, suffix_style: impl Into<AnyTextStyle>, ) -> InputDecoration
Dart InputDecoration(suffixStyle:).
Sourcepub fn suffix_icon_color(
self,
suffix_icon_color: impl Into<AnyColor>,
) -> InputDecoration
pub fn suffix_icon_color( self, suffix_icon_color: impl Into<AnyColor>, ) -> InputDecoration
Dart InputDecoration(suffixIconColor:).
Sourcepub fn suffix_icon_constraints(
self,
suffix_icon_constraints: BoxConstraints,
) -> InputDecoration
pub fn suffix_icon_constraints( self, suffix_icon_constraints: BoxConstraints, ) -> InputDecoration
Dart InputDecoration(suffixIconConstraints:).
Sourcepub fn counter<K>(self, counter: impl IntoWidget<K>) -> InputDecoration
pub fn counter<K>(self, counter: impl IntoWidget<K>) -> InputDecoration
Dart InputDecoration(counter:).
Sourcepub fn counter_text(self, counter_text: impl Into<String>) -> InputDecoration
pub fn counter_text(self, counter_text: impl Into<String>) -> InputDecoration
Dart InputDecoration(counterText:).
Sourcepub fn counter_style(
self,
counter_style: impl Into<AnyTextStyle>,
) -> InputDecoration
pub fn counter_style( self, counter_style: impl Into<AnyTextStyle>, ) -> InputDecoration
Dart InputDecoration(counterStyle:).
Sourcepub fn filled(self, filled: bool) -> InputDecoration
pub fn filled(self, filled: bool) -> InputDecoration
Dart InputDecoration(filled:).
Sourcepub fn fill_color(self, fill_color: impl Into<AnyColor>) -> InputDecoration
pub fn fill_color(self, fill_color: impl Into<AnyColor>) -> InputDecoration
Dart InputDecoration(fillColor:).
Sourcepub fn focus_color(self, focus_color: Color) -> InputDecoration
pub fn focus_color(self, focus_color: Color) -> InputDecoration
Dart InputDecoration(focusColor:).
Sourcepub fn hover_color(self, hover_color: Color) -> InputDecoration
pub fn hover_color(self, hover_color: Color) -> InputDecoration
Dart InputDecoration(hoverColor:).
Sourcepub fn error_border(
self,
error_border: impl Into<InputBorderRef>,
) -> InputDecoration
pub fn error_border( self, error_border: impl Into<InputBorderRef>, ) -> InputDecoration
Dart InputDecoration(errorBorder:).
Sourcepub fn focused_border(
self,
focused_border: impl Into<InputBorderRef>,
) -> InputDecoration
pub fn focused_border( self, focused_border: impl Into<InputBorderRef>, ) -> InputDecoration
Dart InputDecoration(focusedBorder:).
Sourcepub fn focused_error_border(
self,
focused_error_border: impl Into<InputBorderRef>,
) -> InputDecoration
pub fn focused_error_border( self, focused_error_border: impl Into<InputBorderRef>, ) -> InputDecoration
Dart InputDecoration(focusedErrorBorder:).
Sourcepub fn disabled_border(
self,
disabled_border: impl Into<InputBorderRef>,
) -> InputDecoration
pub fn disabled_border( self, disabled_border: impl Into<InputBorderRef>, ) -> InputDecoration
Dart InputDecoration(disabledBorder:).
Sourcepub fn enabled_border(
self,
enabled_border: impl Into<InputBorderRef>,
) -> InputDecoration
pub fn enabled_border( self, enabled_border: impl Into<InputBorderRef>, ) -> InputDecoration
Dart InputDecoration(enabledBorder:).
Sourcepub fn border(self, border: impl Into<InputBorderRef>) -> InputDecoration
pub fn border(self, border: impl Into<InputBorderRef>) -> InputDecoration
Dart InputDecoration(border:).
Sourcepub fn enabled(self, enabled: bool) -> InputDecoration
pub fn enabled(self, enabled: bool) -> InputDecoration
Dart InputDecoration(enabled:).
Sourcepub fn semantic_counter_text(
self,
semantic_counter_text: impl Into<String>,
) -> InputDecoration
pub fn semantic_counter_text( self, semantic_counter_text: impl Into<String>, ) -> InputDecoration
Dart InputDecoration(semanticCounterText:).
Sourcepub fn align_label_with_hint(
self,
align_label_with_hint: bool,
) -> InputDecoration
pub fn align_label_with_hint( self, align_label_with_hint: bool, ) -> InputDecoration
Dart InputDecoration(alignLabelWithHint:).
Sourcepub fn constraints(self, constraints: BoxConstraints) -> InputDecoration
pub fn constraints(self, constraints: BoxConstraints) -> InputDecoration
Dart InputDecoration(constraints:).
Sourcepub fn visual_density(self, visual_density: VisualDensity) -> InputDecoration
pub fn visual_density(self, visual_density: VisualDensity) -> InputDecoration
Dart InputDecoration(visualDensity:).
Sourcepub fn supporting_text_padding(
self,
supporting_text_padding: impl Into<EdgeInsetsGeometry>,
) -> InputDecoration
pub fn supporting_text_padding( self, supporting_text_padding: impl Into<EdgeInsetsGeometry>, ) -> InputDecoration
Dart InputDecoration(supportingTextPadding:).
Sourcepub fn copy_with(&self) -> InputDecoration
pub fn copy_with(&self) -> InputDecoration
Creates a copy of this input decoration with the given fields replaced by the new values.
Dart’s named arguments are the fluent setters on the copy
(decoration.copy_with().label_text("Name")).
Sourcepub fn apply_defaults(
&self,
input_decoration_theme: impl Into<InputDecorationThemeData>,
) -> InputDecoration
pub fn apply_defaults( &self, input_decoration_theme: impl Into<InputDecorationThemeData>, ) -> InputDecoration
Used by widgets like TextField and InputDecorator to create a new
InputDecoration with default values taken from the input_decoration_theme.
Only null valued properties from this InputDecoration are replaced
by the corresponding values from input_decoration_theme.
Dart’s parameter is an Object that must be an InputDecorationTheme or an
InputDecorationThemeData; here either converts into the data.
Trait Implementations§
Source§impl Clone for InputDecoration
impl Clone for InputDecoration
Source§impl Debug for InputDecoration
Dart’s toString.
impl Debug for InputDecoration
Dart’s toString.
Source§impl Default for InputDecoration
impl Default for InputDecoration
Source§fn default() -> InputDecoration
fn default() -> InputDecoration
Source§impl Display for InputDecoration
Dart’s InputDecoration.toString, which Debug already renders.
impl Display for InputDecoration
Dart’s InputDecoration.toString, which Debug already renders.