pushClipRect method
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 bypainter
.painter
is a callback that will paint with theclipRect
applied. This function calls thepainter
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));
}
}