copyWith method

CNButtonData copyWith({
  1. String? label,
  2. CNSymbol? icon,
  3. IconData? customIcon,
  4. CNImageAsset? imageAsset,
  5. VoidCallback? onPressed,
  6. bool? enabled,
  7. Color? tint,
  8. CNButtonDataConfig? config,
})

Creates a copy of this data with the given fields replaced.

Implementation

CNButtonData copyWith({
  String? label,
  CNSymbol? icon,
  IconData? customIcon,
  CNImageAsset? imageAsset,
  VoidCallback? onPressed,
  bool? enabled,
  Color? tint,
  CNButtonDataConfig? config,
}) {
  if (isIcon) {
    return CNButtonData.icon(
      icon: icon ?? this.icon,
      customIcon: customIcon ?? this.customIcon,
      imageAsset: imageAsset ?? this.imageAsset,
      onPressed: onPressed ?? this.onPressed,
      enabled: enabled ?? this.enabled,
      tint: tint ?? this.tint,
      config: config ?? this.config,
    );
  }
  return CNButtonData(
    label: label ?? this.label!,
    icon: icon ?? this.icon,
    customIcon: customIcon ?? this.customIcon,
    imageAsset: imageAsset ?? this.imageAsset,
    onPressed: onPressed ?? this.onPressed,
    enabled: enabled ?? this.enabled,
    tint: tint ?? this.tint,
    config: config ?? this.config,
  );
}