Skip to main content

ButtonThemeData

Struct ButtonThemeData 

Source
pub struct ButtonThemeData {
    pub min_width: f64,
    pub height: f64,
    pub text_theme: ButtonTextTheme,
    pub layout_behavior: ButtonBarLayoutBehavior,
    pub aligned_dropdown: bool,
    pub color_scheme: Option<ColorScheme>,
    /* private fields */
}
Expand description

Used with ButtonTheme to configure the color and geometry of buttons.

This class is planned to be deprecated in a future release. Please use one or more of these buttons and associated themes instead:

  • TextButton, TextButtonTheme, TextButtonThemeData,
  • ElevatedButton, ElevatedButtonTheme, ElevatedButtonThemeData,
  • OutlinedButton, OutlinedButtonTheme, OutlinedButtonThemeData

A button theme can be specified as part of the overall Material theme using ThemeData::button_theme. The Material theme’s button theme data can be overridden with ButtonTheme.

padding and shape are getters that fall back to a default for the text_theme, so the fields hold only what was given; copy_with, as Dart’s copyWith, keeps the worked-out values.

Fields§

§min_width: f64

The minimum width for buttons.

The actual horizontal space allocated for a button’s child is at least this value less the theme’s horizontal padding.

Defaults to 88.0 logical pixels.

§height: f64

The minimum height for buttons.

Defaults to 36.0 logical pixels.

§text_theme: ButtonTextTheme

Defines a button’s base colors, and the defaults for the button’s minimum size, internal padding, and shape.

Despite the name, this property is not a TextTheme, its value is not a collection of TextStyles.

§layout_behavior: ButtonBarLayoutBehavior

Defines whether a ButtonBar should size itself with a minimum size constraint or with padding.

Defaults to ButtonBarLayoutBehavior::Padded.

§aligned_dropdown: bool

If true, then a DropdownButton menu’s width will match the button’s width.

If false (the default), then the dropdown’s menu will be wider than its button. In either case the dropdown button will line up the leading edge of the menu’s value with the leading edge of the values displayed by the menu items.

This property only affects DropdownButton and its menu.

§color_scheme: Option<ColorScheme>

A set of thirteen colors that can be used to derive the button theme’s colors.

This property was added much later than the theme’s set of highly specific colors, like ThemeData::highlight_color and ThemeData::splash_color etc.

The colors for new button classes can be defined exclusively in terms of color_scheme. When it’s possible, the existing buttons will (continue to) gradually migrate to it.

Implementations§

Source§

impl ButtonThemeData

Source

pub fn new() -> ButtonThemeData

Create a button theme object that can be used with ButtonTheme or ThemeData.

The min_width and height parameters must greater than or equal to zero.

Source

pub fn with_text_theme(self, text_theme: ButtonTextTheme) -> ButtonThemeData

Dart ButtonThemeData(textTheme:).

Source

pub fn with_min_width(self, min_width: f64) -> ButtonThemeData

Dart ButtonThemeData(minWidth:).

Source

pub fn with_height(self, height: f64) -> ButtonThemeData

Dart ButtonThemeData(height:).

Source

pub fn with_padding( self, padding: impl Into<EdgeInsetsGeometry>, ) -> ButtonThemeData

Dart ButtonThemeData(padding:).

Source

pub fn with_shape(self, shape: impl Into<ShapeBorderRef>) -> ButtonThemeData

Dart ButtonThemeData(shape:).

Source

pub fn with_layout_behavior( self, layout_behavior: ButtonBarLayoutBehavior, ) -> ButtonThemeData

Dart ButtonThemeData(layoutBehavior:).

Source

pub fn with_aligned_dropdown(self, aligned_dropdown: bool) -> ButtonThemeData

Dart ButtonThemeData(alignedDropdown:).

Source

pub fn with_button_color(self, button_color: Color) -> ButtonThemeData

Dart ButtonThemeData(buttonColor:).

Source

pub fn with_disabled_color(self, disabled_color: Color) -> ButtonThemeData

Dart ButtonThemeData(disabledColor:).

Source

pub fn with_focus_color(self, focus_color: Color) -> ButtonThemeData

Dart ButtonThemeData(focusColor:).

Source

pub fn with_hover_color(self, hover_color: Color) -> ButtonThemeData

Dart ButtonThemeData(hoverColor:).

Source

pub fn with_highlight_color(self, highlight_color: Color) -> ButtonThemeData

Dart ButtonThemeData(highlightColor:).

Source

pub fn with_splash_color(self, splash_color: Color) -> ButtonThemeData

Dart ButtonThemeData(splashColor:).

Source

pub fn with_color_scheme(self, color_scheme: ColorScheme) -> ButtonThemeData

Dart ButtonThemeData(colorScheme:).

Source

pub fn with_material_tap_target_size( self, material_tap_target_size: MaterialTapTargetSize, ) -> ButtonThemeData

Dart ButtonThemeData(materialTapTargetSize:).

Source

pub fn constraints(&self) -> BoxConstraints

Convenience that returns min_width and height as a BoxConstraints object.

Source

pub fn padding(&self) -> EdgeInsetsGeometry

Padding for a button’s child (typically the button’s label).

Defaults to 24.0 on the left and right if text_theme is ButtonTextTheme::Primary, 16.0 on the left and right otherwise.

Source

pub fn shape(&self) -> ShapeBorderRef

The shape of a button’s material.

The button’s highlight and splash are clipped to this shape. If the button has an elevation, then its drop shadow is defined by this shape as well.

Defaults to a rounded rectangle with circular corner radii of 4.0 if text_theme is ButtonTextTheme::Primary, a rounded rectangle with circular corner radii of 2.0 otherwise.

Source

pub fn get_brightness(&self, button: &MaterialButton) -> Brightness

The button’s overall brightness.

Returns the button’s colorBrightness if it is non-null, otherwise the color scheme’s brightness.

Source

pub fn get_text_theme(&self, button: &MaterialButton) -> ButtonTextTheme

Defines the button’s base colors, and the defaults for the button’s minimum size, internal padding, and shape.

Source

pub fn get_disabled_text_color(&self, button: &MaterialButton) -> Color

The foreground color of the button’s text and icon when on_pressed is null.

Source

pub fn get_disabled_fill_color(&self, button: &MaterialButton) -> Color

The button’s background color when on_pressed is null.

Source

pub fn get_fill_color(&self, button: &MaterialButton) -> Option<Color>

The button’s background fill color, or None for buttons that don’t have a background color.

Source

pub fn get_text_color(&self, button: &MaterialButton) -> Color

The foreground color of the button’s text and icon.

Source

pub fn get_splash_color(&self, button: &MaterialButton) -> Color

The color of the ink “splash” overlay that appears when the (enabled) button is tapped.

Source

pub fn get_focus_color(&self, button: &MaterialButton) -> Color

The fill color of the button when it has input focus.

Source

pub fn get_hover_color(&self, button: &MaterialButton) -> Color

The fill color of the button when a pointer is hovering over it.

Source

pub fn get_highlight_color(&self, button: &MaterialButton) -> Color

The color of the overlay that appears when the button is pressed.

Source

pub fn get_elevation(&self, button: &MaterialButton) -> f64

The button’s elevation when it is enabled and has not been pressed.

Source

pub fn get_focus_elevation(&self, button: &MaterialButton) -> f64

The button’s elevation when it is enabled and has focus.

Source

pub fn get_hover_elevation(&self, button: &MaterialButton) -> f64

The button’s elevation when it is enabled and hovered.

Source

pub fn get_highlight_elevation(&self, button: &MaterialButton) -> f64

The button’s elevation when it is enabled and pressed.

Source

pub fn get_disabled_elevation(&self, button: &MaterialButton) -> f64

The button’s elevation when on_pressed is null.

Source

pub fn get_padding(&self, button: &MaterialButton) -> EdgeInsetsGeometry

Padding for the button’s child (typically the button’s label).

Source

pub fn get_shape(&self, button: &MaterialButton) -> ShapeBorderRef

The shape of the button’s Material.

Source

pub fn get_animation_duration(&self, button: &MaterialButton) -> Duration

The duration of the button’s highlight animation.

Source

pub fn get_constraints(&self, _button: &MaterialButton) -> BoxConstraints

The BoxConstraints that define the button’s size.

Source

pub fn get_material_tap_target_size( &self, button: &MaterialButton, ) -> MaterialTapTargetSize

The minimum size of the button’s tap target.

Source

pub fn copy_with(&self) -> ButtonThemeData

Creates a copy of this button theme data object with the matching fields replaced with the non-null parameter values.

The copy holds this theme’s padding and shape as given values, their defaults included, as Dart’s copyWith passes this.padding and this.shape on.

Trait Implementations§

Source§

impl Clone for ButtonThemeData

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 ButtonThemeData

Source§

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

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

impl Default for ButtonThemeData

Source§

fn default() -> ButtonThemeData

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

impl Diagnosticable for ButtonThemeData

Source§

fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)

Add additional properties associated with the node.
Source§

fn type_name(&self) -> &'static str

Dart’s Object.runtimeType as diagnostics print it: the last segment of the Rust type path, without generic arguments.
Source§

fn identity_hash(&self) -> u64

Dart’s Object.hashCode as diagnostics print it: the object’s address.
Source§

fn to_string_short(&self) -> String

A brief description of this object, usually just the type and the hash.
Source§

fn to_diagnostics_node(&self) -> DiagnosticableNode

Returns a debug representation of the object used by debugging tools and by DiagnosticsNode::to_string_deep.
Source§

fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode

Dart toDiagnosticsNode(name:, style:).
Source§

fn to_string(&self) -> String

Dart’s toString: a single-line description with properties and no children. Read more
Source§

fn to_string_at(&self, min_level: DiagnosticLevel) -> String

Dart’s toString(minLevel:).
Source§

impl Display for ButtonThemeData

Source§

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

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

impl PartialEq for ButtonThemeData

Source§

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

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

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

Inequality operator !=. Read more

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