paintMask method

void paintMask(
  1. Canvas canvas,
  2. Rect rect,
  3. ExtendedImageCropLayerPainter painter
)
inherited

Draw the mask over the crop area

Implementation

void paintMask(
  Canvas canvas,
  Rect rect,
  ExtendedImageCropLayerPainter painter,
) {
  final Rect cropRect = painter.cropRect;
  final Color maskColor = painter.maskColor;

  // Save the current layer for later restoration
  canvas.saveLayer(rect, Paint());

  // Clip the crop area and draw the mask outside the crop area
  canvas.clipRect(cropRect, clipOp: ClipOp.difference);
  canvas.drawRect(
      rect,
      Paint()
        ..style = PaintingStyle.fill
        ..color = maskColor);

  // Restore the canvas layer
  canvas.restore();
}