copyWith method

ToggleIconStyle copyWith({
  1. double? size,
  2. Color? color,
  3. double? opacity,
  4. double? scale,
  5. Color? backColor,
  6. double? backOpacity,
  7. bool? mergeResolved,
  8. ToggleIconStyle? selectedStyle,
  9. ToggleIconStyle? disabledStyle,
})

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

Implementation

ToggleIconStyle copyWith({
  double? size,
  Color? color,
  double? opacity,
  double? scale,
  Color? backColor,
  double? backOpacity,
  bool? mergeResolved,
  ToggleIconStyle? selectedStyle,
  ToggleIconStyle? disabledStyle,
}) {
  final style = ToggleIconStyle(
    size: size ?? this.size,
    color: color ?? this.color,
    opacity: opacity ?? this.opacity,
    scale: scale ?? this.scale,
    backColor: backColor ?? this.backColor,
    backOpacity: backOpacity ?? this.backOpacity,
  );

  final hasEventStyle = [
    mergeResolved,
    selectedStyle,
    disabledStyle,
  ].any((el) => el != null);

  if (hasEventStyle) {
    return DrivenToggleIconStyle.from(
      style,
      selectedStyle: selectedStyle,
      disabledStyle: disabledStyle,
      mergeResolved: mergeResolved,
    );
  }
  return style;
}