pushClipPath method

ClipPathLayer pushClipPath (bool needsCompositing, Offset offset, Rect bounds, Path clipPath, PaintingContextCallback painter, { Clip clipBehavior: Clip.antiAlias, ClipPathLayer oldLayer })

Clip further painting using a path.

null

  • offset is the offset from the origin of the canvas' coordinate system to the origin of the caller's coordinate system.
  • bounds is the region of the canvas (in the caller's coordinate system) into which painter will paint in.
  • clipPath is the path (in the coordinate system of the caller) to use to clip the painting done by painter.
  • painter is a callback that will paint with the clipPath applied. This function calls the painter synchronously.
  • clipBehavior controls how the rounded rectangle is clipped. null

Implementation

ClipPathLayer pushClipPath(bool needsCompositing, Offset offset, Rect bounds, Path clipPath, PaintingContextCallback painter, { Clip clipBehavior = Clip.antiAlias, ClipPathLayer oldLayer }) {
  assert(clipBehavior != null);
  final Rect offsetBounds = bounds.shift(offset);
  final Path offsetClipPath = clipPath.shift(offset);
  if (needsCompositing) {
    final ClipPathLayer layer = oldLayer ?? ClipPathLayer();
    layer
      ..clipPath = offsetClipPath
      ..clipBehavior = clipBehavior;
    pushLayer(layer, painter, offset, childPaintBounds: offsetBounds);
    return layer;
  } else {
    clipPathAndPaint(offsetClipPath, clipBehavior, offsetBounds, () => painter(this, offset));
    return null;
  }
}