clipPath method

void clipPath({
  1. required Path path,
  2. required VoidCallback paint,
  3. Clip clipBehavior = Clip.antiAlias,
  4. Offset offset = Offset.zero,
  5. Rect? bounds,
  6. LayerKey<Layer>? key,
})

Pushes a ClipPathLayer to the compositing tree, calling paint to paint on top of the layer.

The bounds argument defines the bounds in which the paint should paint, this is useful for debugging tools and does not affect rendering.

See also:

Implementation

void clipPath({
  required Path path,
  required VoidCallback paint,
  Clip clipBehavior = Clip.antiAlias,
  Offset offset = Offset.zero,
  Rect? bounds,
  LayerKey? key,
}) {
  final offsetClipPath = path.shift(offset + _render.paintOffset!);
  ClipPathLayer layer;
  if (key?.layer is ClipPathLayer) {
    layer = (key!.layer! as ClipPathLayer)
      ..clipPath = offsetClipPath
      ..clipBehavior = clipBehavior;
  } else {
    layer = ClipPathLayer(
      clipPath: offsetClipPath,
      clipBehavior: clipBehavior,
    );
    key?.layer = layer;
  }
  push(layer: layer, paint: paint, offset: offset, bounds: bounds);
}