ButtonVariant class abstract

Defines the visual appearance of a Button.

Extend this class to create your own variants:

class MyBrandVariant extends ButtonVariant {
  const MyBrandVariant();

  @override
  ButtonVariantStyle resolve(ColorScheme cs) {
    return ButtonVariantStyle(
      backgroundColor: cs.brand,
      foregroundColor: cs.onBrand,
      shadows: [BoxShadow(color: cs.brand.withValues(alpha: 0.35), ...)],
    );
  }
}

// Then use it:
Button(label: Text('Go'), variant: const MyBrandVariant(), onPressed: ...)

Built-in variants are available as static constants on this class: ButtonVariant.primary, ButtonVariant.secondary, ButtonVariant.tertiary, ButtonVariant.ghost, ButtonVariant.destructive, ButtonVariant.success.

Annotations

Constructors

ButtonVariant()
Const constructor for subclasses.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(ColorScheme colorScheme) ButtonVariantStyle
Resolves the visual style for this variant against colorScheme.
toString() String
A string representation of this object.
inherited

Operators

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

Constants

destructive → const ButtonVariant
Solid danger fill; irreversible or destructive actions.
ghost → const ButtonVariant
No background or border; lowest-emphasis actions.
primary → const ButtonVariant
Solid brand fill; the default primary call-to-action.
secondary → const ButtonVariant
Outlined button on a surface background; secondary actions.
success → const ButtonVariant
Solid success fill; confirmation or positive actions.
tertiary → const ButtonVariant
Subtle filled button with a light border; lower-priority actions.