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: f64The 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: f64The minimum height for buttons.
Defaults to 36.0 logical pixels.
text_theme: ButtonTextThemeDefines 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: ButtonBarLayoutBehaviorDefines whether a ButtonBar should size itself with a minimum size constraint or with
padding.
Defaults to ButtonBarLayoutBehavior::Padded.
aligned_dropdown: boolIf 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
impl ButtonThemeData
Sourcepub fn new() -> ButtonThemeData
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.
Sourcepub fn with_text_theme(self, text_theme: ButtonTextTheme) -> ButtonThemeData
pub fn with_text_theme(self, text_theme: ButtonTextTheme) -> ButtonThemeData
Dart ButtonThemeData(textTheme:).
Sourcepub fn with_min_width(self, min_width: f64) -> ButtonThemeData
pub fn with_min_width(self, min_width: f64) -> ButtonThemeData
Dart ButtonThemeData(minWidth:).
Sourcepub fn with_height(self, height: f64) -> ButtonThemeData
pub fn with_height(self, height: f64) -> ButtonThemeData
Dart ButtonThemeData(height:).
Sourcepub fn with_padding(
self,
padding: impl Into<EdgeInsetsGeometry>,
) -> ButtonThemeData
pub fn with_padding( self, padding: impl Into<EdgeInsetsGeometry>, ) -> ButtonThemeData
Dart ButtonThemeData(padding:).
Sourcepub fn with_shape(self, shape: impl Into<ShapeBorderRef>) -> ButtonThemeData
pub fn with_shape(self, shape: impl Into<ShapeBorderRef>) -> ButtonThemeData
Dart ButtonThemeData(shape:).
Sourcepub fn with_layout_behavior(
self,
layout_behavior: ButtonBarLayoutBehavior,
) -> ButtonThemeData
pub fn with_layout_behavior( self, layout_behavior: ButtonBarLayoutBehavior, ) -> ButtonThemeData
Dart ButtonThemeData(layoutBehavior:).
Sourcepub fn with_aligned_dropdown(self, aligned_dropdown: bool) -> ButtonThemeData
pub fn with_aligned_dropdown(self, aligned_dropdown: bool) -> ButtonThemeData
Dart ButtonThemeData(alignedDropdown:).
Dart ButtonThemeData(buttonColor:).
Sourcepub fn with_disabled_color(self, disabled_color: Color) -> ButtonThemeData
pub fn with_disabled_color(self, disabled_color: Color) -> ButtonThemeData
Dart ButtonThemeData(disabledColor:).
Sourcepub fn with_focus_color(self, focus_color: Color) -> ButtonThemeData
pub fn with_focus_color(self, focus_color: Color) -> ButtonThemeData
Dart ButtonThemeData(focusColor:).
Sourcepub fn with_hover_color(self, hover_color: Color) -> ButtonThemeData
pub fn with_hover_color(self, hover_color: Color) -> ButtonThemeData
Dart ButtonThemeData(hoverColor:).
Sourcepub fn with_highlight_color(self, highlight_color: Color) -> ButtonThemeData
pub fn with_highlight_color(self, highlight_color: Color) -> ButtonThemeData
Dart ButtonThemeData(highlightColor:).
Sourcepub fn with_splash_color(self, splash_color: Color) -> ButtonThemeData
pub fn with_splash_color(self, splash_color: Color) -> ButtonThemeData
Dart ButtonThemeData(splashColor:).
Sourcepub fn with_color_scheme(self, color_scheme: ColorScheme) -> ButtonThemeData
pub fn with_color_scheme(self, color_scheme: ColorScheme) -> ButtonThemeData
Dart ButtonThemeData(colorScheme:).
Sourcepub fn with_material_tap_target_size(
self,
material_tap_target_size: MaterialTapTargetSize,
) -> ButtonThemeData
pub fn with_material_tap_target_size( self, material_tap_target_size: MaterialTapTargetSize, ) -> ButtonThemeData
Dart ButtonThemeData(materialTapTargetSize:).
Sourcepub fn constraints(&self) -> BoxConstraints
pub fn constraints(&self) -> BoxConstraints
Convenience that returns min_width and height as
a BoxConstraints object.
Sourcepub fn padding(&self) -> EdgeInsetsGeometry
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.
Sourcepub fn shape(&self) -> ShapeBorderRef
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.
Sourcepub fn get_brightness(&self, button: &MaterialButton) -> Brightness
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.
Sourcepub fn get_text_theme(&self, button: &MaterialButton) -> ButtonTextTheme
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.
Sourcepub fn get_disabled_text_color(&self, button: &MaterialButton) -> Color
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.
Sourcepub fn get_disabled_fill_color(&self, button: &MaterialButton) -> Color
pub fn get_disabled_fill_color(&self, button: &MaterialButton) -> Color
The button’s background color when on_pressed is null.
Sourcepub fn get_fill_color(&self, button: &MaterialButton) -> Option<Color>
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.
Sourcepub fn get_text_color(&self, button: &MaterialButton) -> Color
pub fn get_text_color(&self, button: &MaterialButton) -> Color
The foreground color of the button’s text and icon.
Sourcepub fn get_splash_color(&self, button: &MaterialButton) -> Color
pub fn get_splash_color(&self, button: &MaterialButton) -> Color
The color of the ink “splash” overlay that appears when the (enabled) button is
tapped.
Sourcepub fn get_focus_color(&self, button: &MaterialButton) -> Color
pub fn get_focus_color(&self, button: &MaterialButton) -> Color
The fill color of the button when it has input focus.
Sourcepub fn get_hover_color(&self, button: &MaterialButton) -> Color
pub fn get_hover_color(&self, button: &MaterialButton) -> Color
The fill color of the button when a pointer is hovering over it.
Sourcepub fn get_highlight_color(&self, button: &MaterialButton) -> Color
pub fn get_highlight_color(&self, button: &MaterialButton) -> Color
The color of the overlay that appears when the button is pressed.
Sourcepub fn get_elevation(&self, button: &MaterialButton) -> f64
pub fn get_elevation(&self, button: &MaterialButton) -> f64
The button’s elevation when it is enabled and has not been pressed.
Sourcepub fn get_focus_elevation(&self, button: &MaterialButton) -> f64
pub fn get_focus_elevation(&self, button: &MaterialButton) -> f64
The button’s elevation when it is enabled and has focus.
Sourcepub fn get_hover_elevation(&self, button: &MaterialButton) -> f64
pub fn get_hover_elevation(&self, button: &MaterialButton) -> f64
The button’s elevation when it is enabled and hovered.
Sourcepub fn get_highlight_elevation(&self, button: &MaterialButton) -> f64
pub fn get_highlight_elevation(&self, button: &MaterialButton) -> f64
The button’s elevation when it is enabled and pressed.
Sourcepub fn get_disabled_elevation(&self, button: &MaterialButton) -> f64
pub fn get_disabled_elevation(&self, button: &MaterialButton) -> f64
The button’s elevation when on_pressed is null.
Sourcepub fn get_padding(&self, button: &MaterialButton) -> EdgeInsetsGeometry
pub fn get_padding(&self, button: &MaterialButton) -> EdgeInsetsGeometry
Padding for the button’s child (typically the button’s label).
Sourcepub fn get_shape(&self, button: &MaterialButton) -> ShapeBorderRef
pub fn get_shape(&self, button: &MaterialButton) -> ShapeBorderRef
The shape of the button’s Material.
Sourcepub fn get_animation_duration(&self, button: &MaterialButton) -> Duration
pub fn get_animation_duration(&self, button: &MaterialButton) -> Duration
The duration of the button’s highlight animation.
Sourcepub fn get_constraints(&self, _button: &MaterialButton) -> BoxConstraints
pub fn get_constraints(&self, _button: &MaterialButton) -> BoxConstraints
The BoxConstraints that define the button’s size.
Sourcepub fn get_material_tap_target_size(
&self,
button: &MaterialButton,
) -> MaterialTapTargetSize
pub fn get_material_tap_target_size( &self, button: &MaterialButton, ) -> MaterialTapTargetSize
The minimum size of the button’s tap target.
Sourcepub fn copy_with(&self) -> ButtonThemeData
pub fn copy_with(&self) -> ButtonThemeData
Trait Implementations§
Source§impl Clone for ButtonThemeData
impl Clone for ButtonThemeData
Source§impl Debug for ButtonThemeData
impl Debug for ButtonThemeData
Source§impl Default for ButtonThemeData
impl Default for ButtonThemeData
Source§fn default() -> ButtonThemeData
fn default() -> ButtonThemeData
Source§impl Diagnosticable for ButtonThemeData
impl Diagnosticable for ButtonThemeData
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Object.runtimeType as diagnostics print it: the last segment of
the Rust type path, without generic arguments.Source§fn identity_hash(&self) -> u64
fn identity_hash(&self) -> u64
Object.hashCode as diagnostics print it: the object’s address.Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Source§fn to_diagnostics_node(&self) -> DiagnosticableNode
fn to_diagnostics_node(&self) -> DiagnosticableNode
DiagnosticsNode::to_string_deep.Source§fn to_diagnostics_node_with(
&self,
name: Option<String>,
style: Option<DiagnosticsTreeStyle>,
) -> DiagnosticableNode
fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode
toDiagnosticsNode(name:, style:).Source§fn to_string(&self) -> String
fn to_string(&self) -> String
toString: a single-line description with properties and no
children. Read moreSource§fn to_string_at(&self, min_level: DiagnosticLevel) -> String
fn to_string_at(&self, min_level: DiagnosticLevel) -> String
toString(minLevel:).