copyWith method

SpoilerConfig copyWith({
  1. double? particleDensity,
  2. double? particleSpeed,
  3. Color? particleColor,
  4. double? maxParticleSize,
  5. bool? enableFadeAnimation,
  6. double? fadeRadius,
  7. double? fadeEdgeThickness,
  8. bool? isEnabled,
  9. bool? enableGestureReveal,
  10. ParticleConfig? particleConfig,
  11. FadeConfig? fadeConfig,
  12. SpoilerMask? maskConfig,
  13. ValueChanged<bool>? onSpoilerVisibilityChanged,
  14. ShaderConfig? shaderConfig,
})

Implementation

SpoilerConfig copyWith({
  double? particleDensity,
  double? particleSpeed,
  Color? particleColor,
  double? maxParticleSize,
  bool? enableFadeAnimation,
  double? fadeRadius,
  double? fadeEdgeThickness,
  bool? isEnabled,
  bool? enableGestureReveal,
  ParticleConfig? particleConfig,
  FadeConfig? fadeConfig,
  SpoilerMask? maskConfig,
  ValueChanged<bool>? onSpoilerVisibilityChanged,
  ShaderConfig? shaderConfig,
}) {
  final bool legacyParticleOverridesProvided =
      particleDensity != null || particleSpeed != null || particleColor != null || maxParticleSize != null;

  final bool legacyFadeOverridesProvided =
      enableFadeAnimation != null || fadeRadius != null || fadeEdgeThickness != null;

  final ParticleConfig? nextParticleConfig =
      legacyParticleOverridesProvided ? null : (particleConfig ?? this.particleConfig);

  final FadeConfig? nextFadeConfig = legacyFadeOverridesProvided ? null : (fadeConfig ?? this.fadeConfig);

  return SpoilerConfig(
    particleDensity: legacyParticleOverridesProvided ? (particleDensity ?? this.particleDensity) : null,
    particleSpeed: legacyParticleOverridesProvided ? (particleSpeed ?? this.particleSpeed) : null,
    particleColor: legacyParticleOverridesProvided ? (particleColor ?? this.particleColor) : null,
    maxParticleSize: legacyParticleOverridesProvided ? (maxParticleSize ?? this.maxParticleSize) : null,
    enableFadeAnimation: legacyFadeOverridesProvided ? (enableFadeAnimation ?? this.enableFadeAnimation) : null,
    fadeRadius: legacyFadeOverridesProvided ? (fadeRadius ?? this.fadeRadius) : null,
    fadeEdgeThickness: legacyFadeOverridesProvided ? (fadeEdgeThickness ?? this.fadeEdgeThickness) : null,
    particleConfig: nextParticleConfig,
    fadeConfig: nextFadeConfig,
    isEnabled: isEnabled ?? this.isEnabled,
    enableGestureReveal: enableGestureReveal ?? this.enableGestureReveal,
    maskConfig: maskConfig ?? this.maskConfig,
    onSpoilerVisibilityChanged: onSpoilerVisibilityChanged ?? this.onSpoilerVisibilityChanged,
    shaderConfig: shaderConfig ?? this.shaderConfig,
  );
}