Clip further painting using a path.
needsCompositingis whether the child needs compositing. Typically matches the value of RenderObject.needsCompositing for the caller.offsetis the offset from the origin of the canvas' coordinate system to the origin of the caller's coordinate system.boundsis the region of the canvas (in the caller's coodinate system) into whichpainterwill paint in.clipPathis the path (in the coodinate system of the caller) to use to clip the painting done bypainter.painteris a callback that will paint with theclipPathapplied. This function calls thepaintersynchronously.
Source
void pushClipPath(bool needsCompositing, Offset offset, Rect bounds, Path clipPath, PaintingContextCallback painter) {
final Rect offsetBounds = bounds.shift(offset);
final Path offsetClipPath = clipPath.shift(offset);
if (needsCompositing) {
_stopRecordingIfNeeded();
final ClipPathLayer clipLayer = new ClipPathLayer(clipPath: offsetClipPath);
_appendLayer(clipLayer);
final PaintingContext childContext = new PaintingContext._(clipLayer, offsetBounds);
painter(childContext, offset);
childContext._stopRecordingIfNeeded();
} else {
canvas.saveLayer(bounds.shift(offset), _defaultPaint);
canvas.clipPath(clipPath.shift(offset));
painter(this, offset);
canvas.restore();
}
}