copyWith method

CNButtonData copyWith({
  1. String? label,
  2. CNIcon? icon,
  3. VoidCallback? onPressed,
  4. bool? enabled,
  5. CNButtonTheme? theme,
  6. CNButtonDataConfig? config,
})

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

Implementation

CNButtonData copyWith({
  String? label,
  CNIcon? icon,
  VoidCallback? onPressed,
  bool? enabled,
  CNButtonTheme? theme,
  CNButtonDataConfig? config,
}) {
  if (isIcon) {
    return CNButtonData.icon(
      icon: icon ?? this.icon,
      onPressed: onPressed ?? this.onPressed,
      enabled: enabled ?? this.enabled,
      theme: theme ?? this.theme,
      config: config ?? this.config,
    );
  }
  return CNButtonData(
    label: label ?? this.label!,
    icon: icon ?? this.icon,
    onPressed: onPressed ?? this.onPressed,
    enabled: enabled ?? this.enabled,
    theme: theme ?? this.theme,
    config: config ?? this.config,
  );
}