copyWith method

CheckboxStyle copyWith({
  1. double? size,
  2. BoxShape? shape,
  3. EdgeInsetsGeometry? margin,
  4. EdgeInsetsGeometry? padding,
  5. Color? backgroundColor,
  6. double? backgroundOpacity,
  7. int? backgroundAlpha,
  8. Color? borderColor,
  9. double? borderOpacity,
  10. int? borderAlpha,
  11. double? borderWidth,
  12. BorderRadius? borderRadius,
  13. BorderStyle? borderStyle,
  14. double? checkmarkInset,
  15. Color? checkmarkColor,
  16. double? checkmarkOpacity,
  17. int? checkmarkAlpha,
  18. double? checkmarkWeight,
  19. StrokeStyle? checkmarkStyle,
  20. Color? overlayColor,
  21. double? overlayOpacity,
  22. bool? overlayDisabled,
  23. double? overlayRadius,
  24. bool? mergeResolved,
  25. CheckboxStyle? selectedStyle,
  26. CheckboxStyle? indeterminateStyle,
  27. CheckboxStyle? focusedStyle,
  28. CheckboxStyle? hoveredStyle,
  29. CheckboxStyle? pressedStyle,
  30. CheckboxStyle? disabledStyle,
})

Creates a copy of this CheckboxStyle but with the given fields replaced with the new values.

Implementation

CheckboxStyle copyWith({
  double? size,
  BoxShape? shape,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  Color? backgroundColor,
  double? backgroundOpacity,
  int? backgroundAlpha,
  Color? borderColor,
  double? borderOpacity,
  int? borderAlpha,
  double? borderWidth,
  BorderRadius? borderRadius,
  BorderStyle? borderStyle,
  double? checkmarkInset,
  Color? checkmarkColor,
  double? checkmarkOpacity,
  int? checkmarkAlpha,
  double? checkmarkWeight,
  StrokeStyle? checkmarkStyle,
  Color? overlayColor,
  double? overlayOpacity,
  bool? overlayDisabled,
  double? overlayRadius,
  bool? mergeResolved,
  CheckboxStyle? selectedStyle,
  CheckboxStyle? indeterminateStyle,
  CheckboxStyle? focusedStyle,
  CheckboxStyle? hoveredStyle,
  CheckboxStyle? pressedStyle,
  CheckboxStyle? disabledStyle,
}) {
  final style = CheckboxStyle(
    margin: margin ?? this.margin,
    padding: padding ?? this.padding,
    backgroundColor: backgroundColor ?? this.backgroundColor,
    backgroundOpacity: backgroundOpacity ?? this.backgroundOpacity,
    backgroundAlpha: backgroundAlpha ?? this.backgroundAlpha,
    shape: shape ?? this.shape,
    borderColor: borderColor ?? this.borderColor,
    borderOpacity: borderOpacity ?? this.borderOpacity,
    borderAlpha: borderAlpha ?? this.borderAlpha,
    borderWidth: borderWidth ?? this.borderWidth,
    borderRadius: borderRadius ?? this.borderRadius,
    borderStyle: borderStyle ?? this.borderStyle,
    size: size ?? this.size,
    checkmarkInset: checkmarkInset ?? this.checkmarkInset,
    checkmarkColor: checkmarkColor ?? this.checkmarkColor,
    checkmarkOpacity: checkmarkOpacity ?? this.checkmarkOpacity,
    checkmarkAlpha: checkmarkAlpha ?? this.checkmarkAlpha,
    checkmarkWeight: checkmarkWeight ?? this.checkmarkWeight,
    checkmarkStyle: checkmarkStyle ?? this.checkmarkStyle,
    overlayColor: overlayColor ?? this.overlayColor,
    overlayOpacity: overlayOpacity ?? this.overlayOpacity,
    overlayDisabled: overlayDisabled ?? this.overlayDisabled,
    overlayRadius: overlayRadius ?? this.overlayRadius,
  );

  final hasDrivenStyle = [
    mergeResolved,
    selectedStyle,
    indeterminateStyle,
    focusedStyle,
    hoveredStyle,
    pressedStyle,
    disabledStyle,
  ].any((el) => el != null);

  if (hasDrivenStyle) {
    return DrivenCheckboxStyle.from(
      style,
      selectedStyle: selectedStyle,
      indeterminateStyle: indeterminateStyle,
      focusedStyle: focusedStyle,
      hoveredStyle: hoveredStyle,
      pressedStyle: pressedStyle,
      disabledStyle: disabledStyle,
      mergeResolved: mergeResolved,
    );
  }
  return style;
}