pushClipRect method

void pushClipRect (bool needsCompositing, Offset offset, Rect clipRect, PaintingContextCallback painter, { Clip clipBehavior: Clip.hardEdge })

Clip further painting using a rectangle.

  • needsCompositing is whether the child needs compositing. Typically matches the value of RenderObject.needsCompositing for the caller.
  • offset is the offset from the origin of the canvas' coordinate system to the origin of the caller's coordinate system.
  • clipRect is rectangle (in the caller's coordinate system) to use to clip the painting done by painter.
  • painter is a callback that will paint with the clipRect applied. This function calls the painter synchronously.
  • clipBehavior controls how the rectangle is clipped.

Implementation

void pushClipRect(bool needsCompositing, Offset offset, Rect clipRect, PaintingContextCallback painter, {Clip clipBehavior = Clip.hardEdge}) {
  final Rect offsetClipRect = clipRect.shift(offset);
  if (needsCompositing) {
    pushLayer(ClipRectLayer(clipRect: offsetClipRect, clipBehavior: clipBehavior), painter, offset, childPaintBounds: offsetClipRect);
  } else {
    clipRectAndPaint(offsetClipRect, clipBehavior, offsetClipRect, () => painter(this, offset));
  }
}