ButtonVariance class
Implementation of AbstractButtonStyle providing concrete button style variants.
ButtonVariance implements AbstractButtonStyle with state property functions and provides static constants for all standard button variants (primary, secondary, outline, etc.). Each variant is wrapped in a ComponentThemeButtonStyle to enable theme-level customization.
The static variance constants serve as the base styles used by ButtonStyle's named constructors and can be used directly when creating custom button styles.
Example:
// Use a variant directly
Button(
style: ButtonVariance.primary,
child: Text('Click Me'),
)
- Implemented types
- Available extensions
Constructors
-
ButtonVariance({required ButtonStateProperty<
Decoration> decoration, required ButtonStateProperty<MouseCursor> mouseCursor, required ButtonStateProperty<EdgeInsetsGeometry> padding, required ButtonStateProperty<TextStyle> textStyle, required ButtonStateProperty<IconThemeData> iconTheme, required ButtonStateProperty<EdgeInsetsGeometry> margin}) -
Creates a custom ButtonVariance with the specified style properties.
const
Properties
-
decoration
→ ButtonStateProperty<
Decoration> -
Returns the decoration (background, border, shadows) based on button state.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
-
iconTheme
→ ButtonStateProperty<
IconThemeData> -
Returns the icon theme based on button state.
final
-
margin
→ ButtonStateProperty<
EdgeInsetsGeometry> -
Returns the external margin based on button state.
final
-
mouseCursor
→ ButtonStateProperty<
MouseCursor> -
Returns the mouse cursor appearance based on button state.
final
-
padding
→ ButtonStateProperty<
EdgeInsetsGeometry> -
Returns the internal padding based on button state.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
textStyle
→ ButtonStateProperty<
TextStyle> -
Returns the text style based on button state.
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.
override
-
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.
override
Constants
- card → const AbstractButtonStyle
- Card button variant with elevated appearance.
- destructive → const AbstractButtonStyle
- Destructive button variant for delete/remove actions.
- fixed → const AbstractButtonStyle
- Fixed button variant with consistent dimensions.
- ghost → const AbstractButtonStyle
- Ghost button variant with minimal visual presence.
- link → const AbstractButtonStyle
- Link button variant resembling a text hyperlink.
- Menu button variant for dropdown menu triggers.
- Menubar button variant for horizontal menu bars.
- muted → const AbstractButtonStyle
- Muted button variant with subdued appearance.
- outline → const AbstractButtonStyle
- Outline button variant with border and transparent background.
- primary → const AbstractButtonStyle
- Primary button variant with prominent filled appearance.
- secondary → const AbstractButtonStyle
- Secondary button variant with muted appearance.
- text → const AbstractButtonStyle
- Text button variant with only text content.