Skip to main content

ButtonStyle

Struct ButtonStyle 

Source
pub struct ButtonStyle {
Show 18 fields pub text_style: Option<WidgetStateProperty<TextStyle>>, pub background_color: Option<WidgetStateProperty<Color>>, pub foreground_color: Option<WidgetStateProperty<Color>>, pub overlay_color: Option<WidgetStateProperty<Color>>, pub shadow_color: Option<WidgetStateProperty<Color>>, pub elevation: Option<WidgetStateProperty<f32>>, pub padding: Option<WidgetStateProperty<Insets>>, pub minimum_size: Option<WidgetStateProperty<Size>>, pub fixed_size: Option<WidgetStateProperty<Size>>, pub maximum_size: Option<WidgetStateProperty<Size>>, pub icon_color: Option<WidgetStateProperty<Color>>, pub icon_size: Option<WidgetStateProperty<f32>>, pub side: Option<WidgetStateProperty<BorderSide>>, pub shape: Option<WidgetStateProperty<ShapeBorder>>, pub visual_density: Option<VisualDensity>, pub tap_target: Option<TapTarget>, pub alignment: Option<Alignment>, pub icon_alignment: Option<IconAlignment>,
}
Expand description

How a button looks in each state — the reference’s ButtonStyle (material/button_style.dart).

Every field is optional: what is unset falls through to the theme’s style for that kind of button (ButtonTheme), then to the reference’s defaults. A WidgetStateProperty that has no answer for a state falls through the same way, so a style that only says what a button looks like while enabled keeps the default disabled look.

Fields§

§text_style: Option<WidgetStateProperty<TextStyle>>

The label’s type; its colour is the foreground’s.

§background_color: Option<WidgetStateProperty<Color>>

The surface.

§foreground_color: Option<WidgetStateProperty<Color>>

The label’s colour, and the icon’s unless icon_color says otherwise.

§overlay_color: Option<WidgetStateProperty<Color>>

The highlight under a pointer or the keyboard’s focus, and the ripple of a press.

§shadow_color: Option<WidgetStateProperty<Color>>

The shadow’s colour.

§elevation: Option<WidgetStateProperty<f32>>

How far it sits off the surface.

§padding: Option<WidgetStateProperty<Insets>>

The room between the edge and the content.

§minimum_size: Option<WidgetStateProperty<Size>>

The smallest it is, before the visual density.

§fixed_size: Option<WidgetStateProperty<Size>>

The size it is, within the minimum and maximum. An infinite side is left free.

§maximum_size: Option<WidgetStateProperty<Size>>

The largest it is.

§icon_color: Option<WidgetStateProperty<Color>>

The icon’s colour.

§icon_size: Option<WidgetStateProperty<f32>>

The icon’s side.

§side: Option<WidgetStateProperty<BorderSide>>

The outline.

§shape: Option<WidgetStateProperty<ShapeBorder>>

The shape.

§visual_density: Option<VisualDensity>

How compact it is. Unset, the theme’s.

§tap_target: Option<TapTarget>

How much room it reserves for a finger. Unset, the theme’s.

§alignment: Option<Alignment>

Where the content sits inside it.

§icon_alignment: Option<IconAlignment>

Which side of the label an icon goes.

Implementations§

Source§

impl ButtonStyle

Source

pub fn new() -> Self

A style that says nothing.

Source

pub fn background_color(self, property: WidgetStateProperty<Color>) -> Self

The same, its surface property.

Source

pub fn foreground_color(self, property: WidgetStateProperty<Color>) -> Self

The same, its label property.

Source

pub fn overlay_color(self, property: WidgetStateProperty<Color>) -> Self

The same, its highlight and ripple property.

Source

pub fn elevation(self, property: WidgetStateProperty<f32>) -> Self

The same, its elevation property.

Source

pub fn padding(self, property: WidgetStateProperty<Insets>) -> Self

The same, its padding property.

Source

pub fn minimum_size(self, size: Size) -> Self

The same, at least size.

Source

pub fn fixed_size(self, size: Size) -> Self

The same, size exactly where it is finite.

Source

pub fn maximum_size(self, size: Size) -> Self

The same, at most size.

Source

pub fn side(self, property: WidgetStateProperty<BorderSide>) -> Self

The same, its outline property.

Source

pub fn shape(self, shape: ShapeBorder) -> Self

The same, shaped shape in every state.

Source

pub fn icon_color(self, property: WidgetStateProperty<Color>) -> Self

The same, its icon property.

Source

pub fn icon_size(self, size: f32) -> Self

The same, its icon size on a side.

Source

pub fn text_style(self, style: TextStyle) -> Self

The same, its label in style.

Source

pub fn visual_density(self, density: VisualDensity) -> Self

The same, at density.

Source

pub fn tap_target(self, target: TapTarget) -> Self

The same, reserving target for a finger.

Source

pub fn alignment(self, alignment: Alignment) -> Self

The same, its content at alignment.

Source

pub fn icon_alignment(self, alignment: IconAlignment) -> Self

The same, its icon on the alignment side.

Trait Implementations§

Source§

impl Clone for ButtonStyle

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 ButtonStyle

Source§

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

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

impl Default for ButtonStyle

Source§

fn default() -> Self

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

impl PartialEq for ButtonStyle

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ButtonStyle

Auto Trait Implementations§

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<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> 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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

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