ButtonSpec class

Defines the structure and styling properties for a button component.

ButtonSpec is the resolved specification that describes how a button should be styled and structured. It follows the Spec pattern used throughout the Remix framework, where:

  1. Style classes (like ButtonStyler) define styling APIs
  2. Spec classes (like ButtonSpec) hold resolved styling properties
  3. Widget classes (like RemixButton) consume specs to render UI

The ButtonSpec contains StyleSpec properties for each visual element of the button: container layout, text label, icon, and loading spinner. These properties are built by ButtonStyler and consumed by RemixButton to create the final rendered widget.

Architecture Overview

ButtonStyler -> ButtonSpec -> RemixButton Widget
(Define styles)    (Hold props)   (Render UI)

Usage

Specs are typically not created directly by users. Instead, they are built internally when applying styles:

// Style creates and populates the spec
final style = ButtonStyler()
  .color(Colors.blue)
  .label(.color(Colors.white))
  .iconSize(20.0);

// Widget receives the resolved spec
RemixButton(
  style: style,
  onPressed: () {},
  child: Text('Click me'),
)

Properties

Each StyleSpec property corresponds to a visual element:

  • container: Layout and visual styling (flex, background, borders)
  • label: Text styling for the button's label
  • icon: Icon styling when an icon is present
  • spinner: Loading spinner styling during async operations

See also:

Implemented types
Annotations
  • @MixableSpec.new(target: RemixButton.new, extraStylerMixins: [RemixBoxStylerMixin, LabelStyleMixin, IconStyleMixin, SpinnerStyleMixin])

Constructors

ButtonSpec({StyleSpec<FlexBoxSpec>? container, StyleSpec<TextSpec>? label, StyleSpec<IconSpec>? icon, StyleSpec<SpinnerSpec>? spinner, RemixBoxEffectsSpec? containerEffects, RemixIconAlignment? iconAlignment})
Creates a ButtonSpec with optional styling specifications.
const

Properties

container StyleSpec<FlexBoxSpec>
Styling specification for the button's container.
final
containerEffects RemixBoxEffectsSpec?
final
hashCode int
The hash code for this object.
no setterinherited
icon StyleSpec<IconSpec>
Styling specification for the button's icon.
final
iconAlignment RemixIconAlignment?
Placement used when exactly one icon is present.
final
label StyleSpec<TextSpec>
Styling specification for the button's text label.
final
props List<Object?>
The properties based on which equality and hash code are computed.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
spinner StyleSpec<SpinnerSpec>
Styling specification for the button's loading spinner.
final
stringify bool
Whether to use a detailed string representation of the object.
no setterinherited
type Type
no setterinherited

Methods

copyWith({StyleSpec<FlexBoxSpec>? container, StyleSpec<TextSpec>? label, StyleSpec<IconSpec>? icon, StyleSpec<SpinnerSpec>? spinner, RemixBoxEffectsSpec? containerEffects, RemixIconAlignment? iconAlignment}) ButtonSpec
Creates a copy of this spec with the given fields replaced by the non-null parameter values.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
getDiff(Equatable other) Map<String, String>
Returns a map of properties that differ between this object and another.
inherited
lerp(covariant ButtonSpec? other, double t) ButtonSpec
Linearly interpolates with another Spec object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

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