Skip to main content

SelectableChipAttributes

Trait SelectableChipAttributes 

Source
pub trait SelectableChipAttributes {
    // Required methods
    fn selected(&self) -> bool;
    fn on_selected(&self) -> Option<&ValueChanged<bool>>;
    fn press_elevation(&self) -> Option<f64>;
    fn selected_color(&self) -> Option<Color>;
    fn selected_shadow_color(&self) -> Option<Color>;
    fn tooltip(&self) -> Option<&str>;
    fn avatar_border(&self) -> &ShapeBorderRef;
}
Expand description

An interface for Material Design chips that can be selected.

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:

  • 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.
  • https://material.io/design/components/chips.html

Required Methods§

Source

fn selected(&self) -> bool

Whether or not this chip is selected.

If on_selected is not null, this value will be used to determine if the select check mark will be shown or not.

Defaults to false.

Source

fn on_selected(&self) -> Option<&ValueChanged<bool>>

Called when the chip should change between selected and de-selected states.

When the chip is tapped, then the on_selected callback, if set, will be applied to !selected (see selected).

The chip passes the new value to the callback but does not actually change state until the parent widget rebuilds the chip with the new value.

The callback provided to on_selected should update the state of the parent StatefulWidget using the State::set_state method, so that the parent gets rebuilt.

The on_selected and TappableChipAttributes::on_pressed callbacks must not both be specified at the same time.

Source

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

Elevation to be applied on the chip relative to its parent during the press motion.

This controls the size of the shadow below the chip.

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

Source

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

Color to be used for the chip’s background, indicating that it is selected.

The chip is selected when selected is true.

Source

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

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

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

Source

fn tooltip(&self) -> Option<&str>

Tooltip string to be used for the body area (where the label and avatar are) of the chip.

Source

fn avatar_border(&self) -> &ShapeBorderRef

The shape for the avatar’s border: the check mark’s scrim is clipped to it.

Defaults to a CircleBorder.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§