copyWith method

CardProps copyWith({
  1. Widget? child,
  2. List<Widget>? children,
  3. CardVariant? variant,
  4. EdgeInsets? padding,
  5. BorderRadius? borderRadius,
  6. String? backgroundColor,
  7. bool? fillWidth,
  8. void onTap()?,
  9. String? href,
  10. bool clearInteraction = false,
  11. String? target,
  12. String? rel,
  13. String? classes,
  14. Map<String, String>? attributes,
  15. String? ariaLabel,
  16. ArcaneStyleData? styles,
  17. ArcaneDecoration? decoration,
})

Implementation

CardProps copyWith({
  Widget? child,
  List<Widget>? children,
  CardVariant? variant,
  EdgeInsets? padding,
  BorderRadius? borderRadius,
  String? backgroundColor,
  bool? fillWidth,
  void Function()? onTap,
  String? href,
  bool clearInteraction = false,
  String? target,
  String? rel,
  String? classes,
  Map<String, String>? attributes,
  String? ariaLabel,
  ArcaneStyleData? styles,
  ArcaneDecoration? decoration,
}) {
  assert(
    href == null || onTap == null,
    'CardProps.copyWith href and onTap are mutually exclusive',
  );
  assert(
    !clearInteraction || (href == null && onTap == null),
    'clearInteraction cannot be combined with href or onTap',
  );

  // Supplying either interaction mode intentionally replaces the other.
  // `clearInteraction` is the explicit nullable sentinel for returning a
  // card to its static div form.
  final String? nextHref = clearInteraction
      ? null
      : href ?? (onTap == null ? this.href : null);
  final void Function()? nextOnTap = clearInteraction || href != null
      ? null
      : onTap ?? this.onTap;

  return CardProps(
    child: child ?? this.child,
    children: children ?? this.children,
    variant: variant ?? this.variant,
    padding: padding ?? this.padding,
    borderRadius: borderRadius ?? this.borderRadius,
    backgroundColor: backgroundColor ?? this.backgroundColor,
    fillWidth: fillWidth ?? this.fillWidth,
    onTap: nextOnTap,
    href: nextHref,
    target: target ?? this.target,
    rel: rel ?? this.rel,
    classes: classes ?? this.classes,
    attributes: attributes ?? this.attributes,
    ariaLabel: ariaLabel ?? this.ariaLabel,
    styles: styles ?? this.styles,
    decoration: decoration ?? this.decoration,
  );
}