copyWith method

  1. @override
TextSpoilerConfig 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,
  15. TextStyle? textStyle,
  16. TextSelection? textSelection,
  17. TextAlign? textAlign,
  18. int? maxLines,
  19. bool? isEllipsis,
})
override

Implementation

@override
TextSpoilerConfig 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,
  TextStyle? textStyle,
  TextSelection? textSelection,
  TextAlign? textAlign,
  int? maxLines,
  bool? isEllipsis,
}) {
  final bool legacyParticleOverrides =
      particleDensity != null || particleSpeed != null || particleColor != null || maxParticleSize != null;

  final ParticleConfig nextParticleConfig = particleConfig ??
      (legacyParticleOverrides
          ? ParticleConfig(
              density: particleDensity ?? this.particleConfig.density,
              speed: particleSpeed ?? this.particleConfig.speed,
              color: particleColor ?? this.particleConfig.color,
              maxParticleSize: maxParticleSize ?? this.particleConfig.maxParticleSize,
              shapePreset: this.particleConfig.shapePreset,
            )
          : this.particleConfig);

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

  final FadeConfig? nextFadeConfig = fadeConfig ??
      (legacyFadeOverrides
          ? ((enableFadeAnimation ?? (this.fadeConfig != null))
              ? FadeConfig(
                  padding: fadeRadius ?? (this.fadeConfig?.padding ?? 10.0),
                  edgeThickness: fadeEdgeThickness ?? (this.fadeConfig?.edgeThickness ?? 20.0),
                )
              : null)
          : this.fadeConfig);

  return TextSpoilerConfig(
    particleConfig: nextParticleConfig,
    fadeConfig: nextFadeConfig,
    isEnabled: isEnabled ?? this.isEnabled,
    enableGestureReveal: enableGestureReveal ?? this.enableGestureReveal,
    maskConfig: maskConfig ?? this.maskConfig,
    onSpoilerVisibilityChanged: onSpoilerVisibilityChanged ?? this.onSpoilerVisibilityChanged,
    textStyle: textStyle ?? this.textStyle,
    textSelection: textSelection ?? this.textSelection,
    textAlign: textAlign ?? this.textAlign,
    maxLines: maxLines ?? this.maxLines,
    isEllipsis: isEllipsis ?? this.isEllipsis,
    shaderConfig: shaderConfig ?? this.shaderConfig,
  );
}