copyWith method

CanvasPaint copyWith({
  1. String? fill,
  2. CanvasImagePattern? pattern,
  3. String? stroke,
  4. double? lineWidth,
  5. String? font,
  6. bool clearFill = false,
  7. bool clearPattern = false,
  8. bool clearStroke = false,
})

Creates a copy with selected paint values replaced.

Implementation

CanvasPaint copyWith({
  String? fill,
  CanvasImagePattern? pattern,
  String? stroke,
  double? lineWidth,
  String? font,
  bool clearFill = false,
  bool clearPattern = false,
  bool clearStroke = false,
}) {
  return CanvasPaint(
    fill: clearFill ? null : fill ?? this.fill,
    pattern: clearPattern ? null : pattern ?? this.pattern,
    stroke: clearStroke ? null : stroke ?? this.stroke,
    lineWidth: lineWidth ?? this.lineWidth,
    font: font ?? this.font,
  );
}