ButtonStyle class

Configurable button style combining variance, size, density, and shape.

ButtonStyle implements AbstractButtonStyle and provides a composable way to create button styles by combining a base variance (primary, secondary, outline, etc.) with size, density, and shape modifiers. This allows for flexible button customization while maintaining consistency.

The class provides named constructors for common button variants (primary, secondary, outline, etc.) and can be further customized with size and density options.

Example:

// Create a large primary button
const ButtonStyle.primary(
  size: ButtonSize.large,
  density: ButtonDensity.comfortable,
)

// Create a small outline button with circular shape
const ButtonStyle.outline(
  size: ButtonSize.small,
  shape: ButtonShape.circle,
)
Implemented types
Available extensions

Constructors

ButtonStyle({required AbstractButtonStyle variance, ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a custom ButtonStyle with the specified variance and modifiers.
const
ButtonStyle.card({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a card button style with elevated appearance.
const
ButtonStyle.destructive({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a destructive button style for delete/remove actions.
const
ButtonStyle.destructiveIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates a destructive icon button style with compact icon density.
const
ButtonStyle.fixed({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a fixed-size button style with consistent dimensions.
const
ButtonStyle.fixedIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates a fixed icon button style with compact icon density.
const
ButtonStyle.ghost({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a ghost button style with minimal visual presence.
const
ButtonStyle.ghostIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates a ghost icon button style with compact icon density.
const
Creates a link button style resembling a text hyperlink.
const
ButtonStyle.linkIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates a link icon button style with compact icon density.
const
ButtonStyle.menu({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a menu button style for dropdown menu triggers.
const
ButtonStyle.menubar({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a menubar button style for menubar items.
const
ButtonStyle.muted({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a muted button style with subdued appearance.
const
ButtonStyle.outline({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates an outline button style with border and no background.
const
ButtonStyle.outlineIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates an outline icon button style with compact icon density.
const
ButtonStyle.primary({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a primary button style with prominent filled appearance.
const
ButtonStyle.primaryIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates a primary icon button style with compact icon density.
const
ButtonStyle.secondary({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a secondary button style with muted appearance.
const
ButtonStyle.secondaryIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates a secondary icon button style with compact icon density.
const
ButtonStyle.text({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.normal, ButtonShape shape = ButtonShape.rectangle})
Creates a text-only button style with no background or border.
const
ButtonStyle.textIcon({ButtonSize size = ButtonSize.normal, ButtonDensity density = ButtonDensity.icon, ButtonShape shape = ButtonShape.rectangle})
Creates a text icon button style with compact icon density.
const

Properties

decoration ButtonStateProperty<Decoration>
Returns the decoration (background, border, shadows) based on button state.
no setteroverride
density ButtonDensity
The density configuration affecting spacing and compactness.
final
hashCode int
The hash code for this object.
no setterinherited
iconTheme ButtonStateProperty<IconThemeData>
Returns the icon theme based on button state.
no setteroverride
margin ButtonStateProperty<EdgeInsetsGeometry>
Returns the external margin based on button state.
no setteroverride
mouseCursor ButtonStateProperty<MouseCursor>
Returns the mouse cursor appearance based on button state.
no setteroverride
padding ButtonStateProperty<EdgeInsetsGeometry>
Returns the internal padding based on button state.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shape ButtonShape
The shape configuration (rectangle or circle).
final
size ButtonSize
The size configuration affecting padding and minimum dimensions.
final
textStyle ButtonStateProperty<TextStyle>
Returns the text style based on button state.
no setteroverride
variance AbstractButtonStyle
The base style variance (primary, secondary, outline, etc.).
final

Methods

copyWith({ButtonStatePropertyDelegate<Decoration>? decoration, ButtonStatePropertyDelegate<MouseCursor>? mouseCursor, ButtonStatePropertyDelegate<EdgeInsetsGeometry>? padding, ButtonStatePropertyDelegate<TextStyle>? textStyle, ButtonStatePropertyDelegate<IconThemeData>? iconTheme, ButtonStatePropertyDelegate<EdgeInsetsGeometry>? margin}) AbstractButtonStyle

Available on AbstractButtonStyle, provided by the ButtonStyleExtension extension

Creates a copy of this style with selectively replaced properties.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withBackgroundColor({Color? color, Color? hoverColor, Color? focusColor, Color? disabledColor}) AbstractButtonStyle

Available on AbstractButtonStyle, provided by the ButtonStyleExtension extension

Creates a copy with custom background colors for different states.
withBorder({Border? border, Border? hoverBorder, Border? focusBorder, Border? disabledBorder}) AbstractButtonStyle

Available on AbstractButtonStyle, provided by the ButtonStyleExtension extension

Creates a copy with custom borders for different states.
withBorderRadius({BorderRadiusGeometry? borderRadius, BorderRadiusGeometry? hoverBorderRadius, BorderRadiusGeometry? focusBorderRadius, BorderRadiusGeometry? disabledBorderRadius}) AbstractButtonStyle

Available on AbstractButtonStyle, provided by the ButtonStyleExtension extension

Creates a copy with custom border radius for different states.
withForegroundColor({Color? color, Color? hoverColor, Color? focusColor, Color? disabledColor}) AbstractButtonStyle

Available on AbstractButtonStyle, provided by the ButtonStyleExtension extension

Creates a copy with custom foreground colors for different states.
withPadding({EdgeInsetsGeometry? padding, EdgeInsetsGeometry? hoverPadding, EdgeInsetsGeometry? focusPadding, EdgeInsetsGeometry? disabledPadding}) AbstractButtonStyle

Available on AbstractButtonStyle, provided by the ButtonStyleExtension extension

Creates a copy with custom padding for different states.

Operators

operator ==(Object other) bool
The equality operator.
inherited