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, CNButtonDataConfig config = const CNButtonDataConfig()})
-
Creates an icon-only button data model.
const
Properties
- 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
- 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
- tint → Color?
-
Tint color for the button.
final
Methods
-
copyWith(
{String? label, CNSymbol? icon, IconData? customIcon, CNImageAsset? imageAsset, VoidCallback? onPressed, bool? enabled, Color? tint, 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