copyWith method

Paint copyWith({
  1. BlendMode? blendMode,
  2. Color? color,
  3. ColorFilter? colorFilter,
  4. FilterQuality? filterQuality,
  5. ImageFilter? imageFilter,
  6. bool? invertColors,
  7. bool? isAntiAlias,
  8. MaskFilter? maskFilter,
  9. Shader? shader,
  10. StrokeCap? strokeCap,
  11. StrokeJoin? strokeJoin,
  12. double? strokeMiterLimit,
  13. double? strokeWidth,
  14. PaintingStyle? style,
})

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

Implementation

Paint copyWith({
  BlendMode? blendMode,
  Color? color,
  ColorFilter? colorFilter,
  FilterQuality? filterQuality,
  ImageFilter? imageFilter,
  bool? invertColors,
  bool? isAntiAlias,
  MaskFilter? maskFilter,
  Shader? shader,
  StrokeCap? strokeCap,
  StrokeJoin? strokeJoin,
  double? strokeMiterLimit,
  double? strokeWidth,
  PaintingStyle? style,
}) {
  var paint = Paint()
    ..blendMode = blendMode ?? this.blendMode
    ..color = color ?? this.color
    ..colorFilter = colorFilter ?? this.colorFilter
    ..filterQuality = filterQuality ?? this.filterQuality
    ..imageFilter = imageFilter ?? this.imageFilter
    ..invertColors = invertColors ?? this.invertColors
    ..isAntiAlias = isAntiAlias ?? this.isAntiAlias
    ..maskFilter = maskFilter ?? this.maskFilter
    ..shader = shader ?? this.shader
    ..strokeCap = strokeCap ?? this.strokeCap
    ..strokeJoin = strokeJoin ?? this.strokeJoin
    ..strokeWidth = strokeWidth ?? this.strokeWidth
    ..style = style ?? this.style;

  if (!usingHtmlRenderer) {
    paint.strokeMiterLimit = strokeMiterLimit ?? this.strokeMiterLimit;
  }

  return paint;
}