Skip to main content

ChipAttributes

Trait ChipAttributes 

Source
pub trait ChipAttributes {
Show 21 methods // Required methods fn label(&self) -> &WidgetRef; fn avatar(&self) -> Option<&WidgetRef>; fn label_style(&self) -> Option<&TextStyle>; fn side(&self) -> Option<&AnyBorderSide>; fn shape(&self) -> Option<&OutlinedBorderRef>; fn clip_behavior(&self) -> Clip; fn focus_node(&self) -> Option<&FocusNodeRef>; fn autofocus(&self) -> bool; fn color(&self) -> Option<&WidgetStatePropertyRef<Option<Color>>>; fn background_color(&self) -> Option<Color>; fn padding(&self) -> Option<&EdgeInsetsGeometry>; fn visual_density(&self) -> Option<VisualDensity>; fn label_padding(&self) -> Option<&EdgeInsetsGeometry>; fn material_tap_target_size(&self) -> Option<MaterialTapTargetSize>; fn elevation(&self) -> Option<f64>; fn shadow_color(&self) -> Option<Color>; fn surface_tint_color(&self) -> Option<Color>; fn icon_theme(&self) -> Option<&IconThemeData>; fn avatar_box_constraints(&self) -> Option<BoxConstraints>; fn chip_animation_style(&self) -> Option<&ChipAnimationStyle>; fn mouse_cursor(&self) -> Option<&MouseCursorRef>;
}
Expand description

An interface defining the base attributes for a Material Design chip.

Chips are compact elements that represent an attribute, text, entity, or action.

The defaults mentioned in the documentation for each attribute are what the implementing classes typically use for defaults (but this class doesn’t provide or enforce them).

See also:

  • Chip, a chip that displays information and can be deleted.
  • InputChip, a chip that represents a complex piece of information, such as an entity (person, place, or thing) or conversational text, in a compact form.
  • ChoiceChip, allows a single selection from a set of options. Choice chips contain related descriptive text or categories.
  • FilterChip, uses tags or descriptive words as a way to filter content.
  • ActionChip, represents an action related to primary content.
  • https://material.io/design/components/chips.html

Required Methods§

Source

fn label(&self) -> &WidgetRef

The primary content of the chip.

Typically a Text widget.

Source

fn avatar(&self) -> Option<&WidgetRef>

A widget to display prior to the chip’s label.

Typically a CircleAvatar widget.

Source

fn label_style(&self) -> Option<&TextStyle>

The style to be applied to the chip’s label.

If this is null and ThemeData::use_material3 is true, then TextTheme::label_large is used. Otherwise, TextTheme::body_large is used.

This only has an effect on widgets that respect the DefaultTextStyle, such as Text.

If TextStyle::color is a WidgetStateProperty<Color>, WidgetStateProperty::resolve is used for the following WidgetStates:

Source

fn side(&self) -> Option<&AnyBorderSide>

The color and weight of the chip’s outline.

Defaults to the border side in the ambient ChipThemeData. If the theme border side resolves to null and ThemeData::use_material3 is true, then BorderSide with a ColorScheme::outline color is used when the chip is enabled, and BorderSide with a ColorScheme::on_surface color with an opacity of 0.12 is used when the chip is disabled. Otherwise, it defaults to null.

This value is combined with shape to create a shape decorated with an outline. To omit the outline entirely, pass BorderSide::NONE to side.

If it is a WidgetStateBorderSide, WidgetStateProperty::resolve is used for the following WidgetStates:

Source

fn shape(&self) -> Option<&OutlinedBorderRef>

The OutlinedBorder to draw around the chip.

Defaults to the shape in the ambient ChipThemeData. If the theme shape resolves to null and ThemeData::use_material3 is true, then RoundedRectangleBorder with a circular border radius of 8.0 is used. Otherwise, StadiumBorder is used.

This shape is combined with side to create a shape decorated with an outline. If side is not null or side of shape is BorderSide::NONE, side of shape is ignored. To omit the outline entirely, pass BorderSide::NONE to side.

If it is a WidgetStateOutlinedBorder, WidgetStateProperty::resolve is used for the following WidgetStates:

Source

fn clip_behavior(&self) -> Clip

Defaults to Clip::None.

Source

fn focus_node(&self) -> Option<&FocusNodeRef>

The focus node of the chip’s InkWell.

Source

fn autofocus(&self) -> bool

Whether the chip’s InkWell should focus itself when it is built.

Source

fn color(&self) -> Option<&WidgetStatePropertyRef<Option<Color>>>

The color that fills the chip, in all WidgetStates.

Defaults to null.

Resolves in the following states:

Source

fn background_color(&self) -> Option<Color>

Color to be used for the unselected, enabled chip’s background.

The default is light grey.

Source

fn padding(&self) -> Option<&EdgeInsetsGeometry>

The padding between the contents of the chip and the outside shape.

If this is null and ThemeData::use_material3 is true, then a padding of 8.0 logical pixels on all sides is used. Otherwise, it defaults to a padding of 4.0 logical pixels on all sides.

Source

fn visual_density(&self) -> Option<VisualDensity>

Defines how compact the chip’s layout will be.

Chips are unaffected by horizontal density changes.

See also:

  • ThemeData::visual_density, which specifies the visual_density for all widgets within a Theme.
Source

fn label_padding(&self) -> Option<&EdgeInsetsGeometry>

The padding around the label widget.

By default, this is 4 logical pixels at the beginning and the end of the label, and zero on top and bottom.

Source

fn material_tap_target_size(&self) -> Option<MaterialTapTargetSize>

Configures the minimum size of the tap target.

Defaults to ThemeData::material_tap_target_size.

See also:

Source

fn elevation(&self) -> Option<f64>

Elevation to be applied on the chip relative to its parent.

This controls the size of the shadow below the chip.

Defaults to 0. The value is always non-negative.

Source

fn shadow_color(&self) -> Option<Color>

Color of the chip’s shadow when the elevation is greater than 0.

If this is null and ThemeData::use_material3 is true, then Colors::TRANSPARENT color is used. Otherwise, it defaults to null.

Source

fn surface_tint_color(&self) -> Option<Color>

Color of the chip’s surface tint overlay when its elevation is greater than 0.

This is not recommended for use. Material 3 spec introduced a set of tone-based surfaces and surface containers in its ColorScheme, which provide more flexibility. The intention is to eventually remove surface tint color from the framework.

If this is null, defaults to Colors::TRANSPARENT.

Source

fn icon_theme(&self) -> Option<&IconThemeData>

Theme used for all icons in the chip.

If this is null and ThemeData::use_material3 is true, then IconThemeData with a ColorScheme::primary color and a size of 18.0 is used when the chip is enabled, and IconThemeData with a ColorScheme::on_surface color and a size of 18.0 is used when the chip is disabled. Otherwise, it defaults to null.

Source

fn avatar_box_constraints(&self) -> Option<BoxConstraints>

Optional size constraints for the avatar.

When unspecified, defaults to a minimum size of chip height or label height (whichever is greater) and a padding of 8.0 pixels on all sides.

The default constraints ensure that the avatar is accessible. Specifying this parameter enables creation of avatar smaller than the minimum size, but it is not recommended.

Source

fn chip_animation_style(&self) -> Option<&ChipAnimationStyle>

Used to override the default chip animations durations.

If ChipAnimationStyle::enable_animation with duration or reverse duration is provided, it will be used to override the chip enable and disable animation durations. If it is null, then default duration will be 75ms.

If ChipAnimationStyle::select_animation with duration or reverse duration is provided, it will be used to override the chip select and unselect animation durations. If it is null, then default duration will be 195ms.

If ChipAnimationStyle::avatar_drawer_animation with duration or reverse duration is provided, it will be used to override the chip checkmark animation duration. If it is null, then default duration will be 150ms.

If ChipAnimationStyle::delete_drawer_animation with duration or reverse duration is provided, it will be used to override the chip delete icon animation duration. If it is null, then default duration will be 150ms.

Source

fn mouse_cursor(&self) -> Option<&MouseCursorRef>

The cursor for a mouse pointer when it enters or is hovering over the widget.

If mouse_cursor is a WidgetStateMouseCursor, WidgetStateProperty::resolve is used for the following WidgetStates:

If this property is null, WidgetStateMouseCursor::adaptive_clickable will be used.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§