CNButtonData class

Data model for button configuration in CNGlassButtonGroup.

This class holds all the properties needed to render a button without being a widget itself. Use this with CNGlassButtonGroup for cleaner data-driven button groups.

Example:

CNGlassButtonGroup(
  buttons: [
    CNButtonData.icon(
      icon: CNIcon.symbol('house'),
      onPressed: () => print('Home'),
    ),
    CNButtonData.icon(
      icon: CNIcon.symbol('gear'),
      onPressed: () => print('Settings'),
    ),
  ],
)

Constructors

CNButtonData({required String? label, CNIcon? icon, VoidCallback? onPressed, bool enabled = true, CNButtonTheme theme = const CNButtonTheme(), CNButtonDataConfig config = const CNButtonDataConfig()})
Creates a button data model with a label.
const
CNButtonData.icon({CNIcon? icon, VoidCallback? onPressed, bool enabled = true, CNButtonTheme theme = const CNButtonTheme(), CNButtonDataConfig config = const CNButtonDataConfig()})
Creates an icon-only button data model.
const

Properties

config → CNButtonDataConfig
Configuration for the button appearance.
final
enabled → bool
Whether the button is enabled.
final
hashCode → int
The hash code for this object.
no setterinherited
icon → CNIcon?
Image/icon asset to display. Use CNIcon.symbol, CNIcon.xcasset, CNIcon.asset, CNIcon.png, CNIcon.svg, etc.
final
isIcon → bool
Whether this is an icon-only button.
final
label → String?
The text label for the button. Null for icon-only buttons.
final
onPressed → VoidCallback?
Callback when the button is pressed.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
theme → CNButtonTheme
Color and material theme for this button.
final

Methods

copyWith({String? label, CNIcon? icon, VoidCallback? onPressed, bool? enabled, CNButtonTheme? theme, CNButtonDataConfig? config}) → CNButtonData
Creates a copy of this data with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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