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: CNSFSymbol.house,
      onPressed: () => print('Home'),
    ),
    CNButtonData.icon(
      icon: CNSFSymbol.gear,
      onPressed: () => print('Settings'),
    ),
  ],
)

Constructors

CNButtonData({required String? label, CNSymbol? icon, IconData? customIcon, CNImageAsset? imageAsset, VoidCallback? onPressed, bool enabled = true, Color? tint, CNButtonDataConfig config = const CNButtonDataConfig()})
Creates a button data model with a label.
const
CNButtonData.icon({CNSymbol? icon, IconData? customIcon, CNImageAsset? imageAsset, VoidCallback? onPressed, bool enabled = true, Color? tint, int? badgeCount, CNButtonDataConfig config = const CNButtonDataConfig()})
Creates an icon-only button data model.
const
CNButtonData.popup({CNSymbol? icon, IconData? customIcon, CNImageAsset? imageAsset, required List<CNButtonDataPopupItem>? popupItems, required ValueChanged<int>? onMenuSelected, bool enabled = true, Color? tint, CNButtonDataConfig config = const CNButtonDataConfig()})
Creates an icon-only popup menu button.
const

Properties

badgeCount → int?
Optional badge count to display on icon buttons. Displayed as "99+" for counts > 99. Only applies to icon-only buttons.
final
config → CNButtonDataConfig
Configuration for the button appearance.
final
customIcon → IconData?
Custom Flutter IconData to render as an image.
final
enabled → bool
Whether the button is enabled.
final
hashCode → int
The hash code for this object.
no setterinherited
icon → CNSymbol?
SF Symbol icon to display.
final
imageAsset → CNImageAsset?
Image asset to display.
final
isIcon → bool
Whether this is an icon-only button.
final
isPopup → bool
Whether this is a popup menu button.
no setter
label → String?
The text label for the button. Null for icon-only buttons.
final
onMenuSelected → ValueChanged<int>?
Callback when a popup menu item is selected. Receives the selected index.
final
onPressed → VoidCallback?
Callback when the button is pressed.
final
popupItems → List<CNButtonDataPopupItem>?
Menu items for popup buttons. When non-null and non-empty, this is a popup button.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tint → Color?
Tint color for the button.
final

Methods

copyWith({String? label, CNSymbol? icon, IconData? customIcon, CNImageAsset? imageAsset, VoidCallback? onPressed, bool? enabled, Color? tint, int? badgeCount, CNButtonDataConfig? config, List<CNButtonDataPopupItem>? popupItems, ValueChanged<int>? onMenuSelected}) → 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