Skip to main content

InputDecoration

Struct InputDecoration 

Source
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 an InputDecoration.
  • InputDecorator, which is a widget that draws an InputDecoration around an input child widget.
  • Decoration and DecoratedBox, 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 the error_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: bool
👎Deprecated:

Use 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: bool

Whether 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: bool

Whether 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 the helper_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_alignment which 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_behavior which 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:

  • Icon and ImageIcon, which are typically used to show icons.
  • prefix and prefix_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.
  • Align A 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:

  • Icon and ImageIcon, which are typically used to show icons.
  • suffix and suffix_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.
  • Align A 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 the InputDecorator’s child has the focus.
  • InputDecoration::error_text, the error shown by the InputDecorator, if non-null.
  • border, for a description of where the InputDecorator border appears.
  • UnderlineInputBorder, an InputDecorator border which draws a horizontal line at the bottom of the input decorator’s container.
  • OutlineInputBorder, an InputDecorator border which draws a rounded rectangle around the input decorator’s container.
  • InputBorderRef::none(), which doesn’t draw a border.
  • focused_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is null.
  • focused_error_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is non-null.
  • disabled_border, displayed when InputDecoration::enabled is false and InputDecoration::error_text is null.
  • enabled_border, displayed when InputDecoration::enabled is true and InputDecoration::error_text is 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 the InputDecorator’s child has the focus.
  • InputDecoration::error_text, the error shown by the InputDecorator, if non-null.
  • border, for a description of where the InputDecorator border appears.
  • UnderlineInputBorder, an InputDecorator border which draws a horizontal line at the bottom of the input decorator’s container.
  • OutlineInputBorder, an InputDecorator border which draws a rounded rectangle around the input decorator’s container.
  • InputBorderRef::none(), which doesn’t draw a border.
  • error_border, displayed when InputDecorator::is_focused is false and InputDecoration::error_text is non-null.
  • focused_error_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is non-null.
  • disabled_border, displayed when InputDecoration::enabled is false and InputDecoration::error_text is null.
  • enabled_border, displayed when InputDecoration::enabled is true and InputDecoration::error_text is 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 the InputDecorator’s child has the focus.
  • InputDecoration::error_text, the error shown by the InputDecorator, if non-null.
  • border, for a description of where the InputDecorator border appears.
  • UnderlineInputBorder, an InputDecorator border which draws a horizontal line at the bottom of the input decorator’s container.
  • OutlineInputBorder, an InputDecorator border which draws a rounded rectangle around the input decorator’s container.
  • InputBorderRef::none(), which doesn’t draw a border.
  • error_border, displayed when InputDecorator::is_focused is false and InputDecoration::error_text is non-null.
  • focused_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is null.
  • disabled_border, displayed when InputDecoration::enabled is false and InputDecoration::error_text is null.
  • enabled_border, displayed when InputDecoration::enabled is true and InputDecoration::error_text is 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 the InputDecorator is disabled.
  • InputDecoration::error_text, the error shown by the InputDecorator, if non-null.
  • border, for a description of where the InputDecorator border appears.
  • UnderlineInputBorder, an InputDecorator border which draws a horizontal line at the bottom of the input decorator’s container.
  • OutlineInputBorder, an InputDecorator border which draws a rounded rectangle around the input decorator’s container.
  • InputBorderRef::none(), which doesn’t draw a border.
  • error_border, displayed when InputDecorator::is_focused is false and InputDecoration::error_text is non-null.
  • focused_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is null.
  • focused_error_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is non-null.
  • enabled_border, displayed when InputDecoration::enabled is true and InputDecoration::error_text is 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 the InputDecorator is disabled.
  • InputDecoration::error_text, the error shown by the InputDecorator, if non-null.
  • border, for a description of where the InputDecorator border appears.
  • UnderlineInputBorder, an InputDecorator border which draws a horizontal line at the bottom of the input decorator’s container.
  • OutlineInputBorder, an InputDecorator border which draws a rounded rectangle around the input decorator’s container.
  • InputBorderRef::none(), which doesn’t draw a border.
  • error_border, displayed when InputDecorator::is_focused is false and InputDecoration::error_text is non-null.
  • focused_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is null.
  • focused_error_border, displayed when InputDecorator::is_focused is true and InputDecoration::error_text is non-null.
  • disabled_border, displayed when InputDecoration::enabled is false and InputDecoration::error_text is 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, an InputDecorator border which draws a rounded rectangle around the input decorator’s container.
§enabled: bool

If 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 the visual_density for all widgets within a Theme.
  • 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

Source

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.

Source

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.

Source

pub fn icon<K>(self, icon: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(icon:).

Source

pub fn icon_color(self, icon_color: impl Into<AnyColor>) -> InputDecoration

Dart InputDecoration(iconColor:).

Source

pub fn label<K>(self, label: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(label:).

Source

pub fn label_text(self, label_text: impl Into<String>) -> InputDecoration

Dart InputDecoration(labelText:).

Source

pub fn label_style( self, label_style: impl Into<AnyTextStyle>, ) -> InputDecoration

Dart InputDecoration(labelStyle:).

Source

pub fn floating_label_style( self, floating_label_style: impl Into<AnyTextStyle>, ) -> InputDecoration

Dart InputDecoration(floatingLabelStyle:).

Source

pub fn label_text_direction( self, label_text_direction: TextDirection, ) -> InputDecoration

Dart InputDecoration(labelTextDirection:).

Source

pub fn helper<K>(self, helper: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(helper:).

Source

pub fn helper_text(self, helper_text: impl Into<String>) -> InputDecoration

Dart InputDecoration(helperText:).

Source

pub fn helper_style( self, helper_style: impl Into<AnyTextStyle>, ) -> InputDecoration

Dart InputDecoration(helperStyle:).

Source

pub fn helper_max_lines(self, helper_max_lines: i32) -> InputDecoration

Dart InputDecoration(helperMaxLines:).

Source

pub fn hint_text(self, hint_text: impl Into<String>) -> InputDecoration

Dart InputDecoration(hintText:).

Source

pub fn hint<K>(self, hint: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(hint:).

Source

pub fn hint_style(self, hint_style: impl Into<AnyTextStyle>) -> InputDecoration

Dart InputDecoration(hintStyle:).

Source

pub fn hint_text_direction( self, hint_text_direction: TextDirection, ) -> InputDecoration

Dart InputDecoration(hintTextDirection:).

Source

pub fn hint_max_lines(self, hint_max_lines: i32) -> InputDecoration

Dart InputDecoration(hintMaxLines:).

Source

pub fn hint_fade_duration(self, hint_fade_duration: Duration) -> InputDecoration

Dart InputDecoration(hintFadeDuration:).

Source

pub 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.

Dart InputDecoration(maintainHintHeight:).

Source

pub fn maintain_hint_size(self, maintain_hint_size: bool) -> InputDecoration

Dart InputDecoration(maintainHintSize:).

Source

pub fn maintain_label_size(self, maintain_label_size: bool) -> InputDecoration

Dart InputDecoration(maintainLabelSize:).

Source

pub fn error<K>(self, error: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(error:).

Source

pub fn error_text(self, error_text: impl Into<String>) -> InputDecoration

Dart InputDecoration(errorText:).

Source

pub fn error_style( self, error_style: impl Into<AnyTextStyle>, ) -> InputDecoration

Dart InputDecoration(errorStyle:).

Source

pub fn error_max_lines(self, error_max_lines: i32) -> InputDecoration

Dart InputDecoration(errorMaxLines:).

Source

pub fn floating_label_behavior( self, floating_label_behavior: FloatingLabelBehavior, ) -> InputDecoration

Dart InputDecoration(floatingLabelBehavior:).

Source

pub fn floating_label_alignment( self, floating_label_alignment: FloatingLabelAlignment, ) -> InputDecoration

Dart InputDecoration(floatingLabelAlignment:).

Source

pub fn is_collapsed(self, is_collapsed: bool) -> InputDecoration

Dart InputDecoration(isCollapsed:).

Source

pub fn is_dense(self, is_dense: bool) -> InputDecoration

Dart InputDecoration(isDense:).

Source

pub fn content_padding( self, content_padding: impl Into<EdgeInsetsGeometry>, ) -> InputDecoration

Dart InputDecoration(contentPadding:).

Source

pub fn prefix_icon<K>(self, prefix_icon: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(prefixIcon:).

Source

pub fn prefix_icon_constraints( self, prefix_icon_constraints: BoxConstraints, ) -> InputDecoration

Dart InputDecoration(prefixIconConstraints:).

Source

pub fn prefix<K>(self, prefix: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(prefix:).

Source

pub fn prefix_text(self, prefix_text: impl Into<String>) -> InputDecoration

Dart InputDecoration(prefixText:).

Source

pub fn prefix_style( self, prefix_style: impl Into<AnyTextStyle>, ) -> InputDecoration

Dart InputDecoration(prefixStyle:).

Source

pub fn prefix_icon_color( self, prefix_icon_color: impl Into<AnyColor>, ) -> InputDecoration

Dart InputDecoration(prefixIconColor:).

Source

pub fn suffix_icon<K>(self, suffix_icon: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(suffixIcon:).

Source

pub fn suffix<K>(self, suffix: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(suffix:).

Source

pub fn suffix_text(self, suffix_text: impl Into<String>) -> InputDecoration

Dart InputDecoration(suffixText:).

Source

pub fn suffix_style( self, suffix_style: impl Into<AnyTextStyle>, ) -> InputDecoration

Dart InputDecoration(suffixStyle:).

Source

pub fn suffix_icon_color( self, suffix_icon_color: impl Into<AnyColor>, ) -> InputDecoration

Dart InputDecoration(suffixIconColor:).

Source

pub fn suffix_icon_constraints( self, suffix_icon_constraints: BoxConstraints, ) -> InputDecoration

Dart InputDecoration(suffixIconConstraints:).

Source

pub fn counter<K>(self, counter: impl IntoWidget<K>) -> InputDecoration

Dart InputDecoration(counter:).

Source

pub fn counter_text(self, counter_text: impl Into<String>) -> InputDecoration

Dart InputDecoration(counterText:).

Source

pub fn counter_style( self, counter_style: impl Into<AnyTextStyle>, ) -> InputDecoration

Dart InputDecoration(counterStyle:).

Source

pub fn filled(self, filled: bool) -> InputDecoration

Dart InputDecoration(filled:).

Source

pub fn fill_color(self, fill_color: impl Into<AnyColor>) -> InputDecoration

Dart InputDecoration(fillColor:).

Source

pub fn focus_color(self, focus_color: Color) -> InputDecoration

Dart InputDecoration(focusColor:).

Source

pub fn hover_color(self, hover_color: Color) -> InputDecoration

Dart InputDecoration(hoverColor:).

Source

pub fn error_border( self, error_border: impl Into<InputBorderRef>, ) -> InputDecoration

Dart InputDecoration(errorBorder:).

Source

pub fn focused_border( self, focused_border: impl Into<InputBorderRef>, ) -> InputDecoration

Dart InputDecoration(focusedBorder:).

Source

pub fn focused_error_border( self, focused_error_border: impl Into<InputBorderRef>, ) -> InputDecoration

Dart InputDecoration(focusedErrorBorder:).

Source

pub fn disabled_border( self, disabled_border: impl Into<InputBorderRef>, ) -> InputDecoration

Dart InputDecoration(disabledBorder:).

Source

pub fn enabled_border( self, enabled_border: impl Into<InputBorderRef>, ) -> InputDecoration

Dart InputDecoration(enabledBorder:).

Source

pub fn border(self, border: impl Into<InputBorderRef>) -> InputDecoration

Dart InputDecoration(border:).

Source

pub fn enabled(self, enabled: bool) -> InputDecoration

Dart InputDecoration(enabled:).

Source

pub fn semantic_counter_text( self, semantic_counter_text: impl Into<String>, ) -> InputDecoration

Dart InputDecoration(semanticCounterText:).

Source

pub fn align_label_with_hint( self, align_label_with_hint: bool, ) -> InputDecoration

Dart InputDecoration(alignLabelWithHint:).

Source

pub fn constraints(self, constraints: BoxConstraints) -> InputDecoration

Dart InputDecoration(constraints:).

Source

pub fn visual_density(self, visual_density: VisualDensity) -> InputDecoration

Dart InputDecoration(visualDensity:).

Source

pub fn supporting_text_padding( self, supporting_text_padding: impl Into<EdgeInsetsGeometry>, ) -> InputDecoration

Dart InputDecoration(supportingTextPadding:).

Source

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")).

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InputDecoration

Dart’s toString.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InputDecoration

Source§

fn default() -> InputDecoration

Returns the “default value” for a type. Read more
Source§

impl Display for InputDecoration

Dart’s InputDecoration.toString, which Debug already renders.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for InputDecoration

Source§

fn eq(&self, other: &InputDecoration) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for InputDecoration

§

impl !Send for InputDecoration

§

impl !Sync for InputDecoration

§

impl !UnwindSafe for InputDecoration

§

impl Forget for InputDecoration

§

impl Freeze for InputDecoration
where *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, *const RcInner<Paint> is !null: Freeze, PhantomData<RcInner<Paint>>: Freeze, PhantomData<Shadow>: Freeze, PhantomData<FontFeature>: Freeze, PhantomData<FontVariation>: Freeze, *const RcInner<dyn TextStyleExtension> is !null: Freeze, PhantomData<RcInner<dyn TextStyleExtension>>: Freeze, *const RcInner<dyn InputBorder> is !null: Freeze, PhantomData<RcInner<dyn InputBorder>>: Freeze,

§

impl Move for InputDecoration

§

impl Unpin for InputDecoration

§

impl UnsafeUnpin for InputDecoration

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>