pushClipRRect method

ClipRRectLayer pushClipRRect (bool needsCompositing, Offset offset, Rect bounds, RRect clipRRect, PaintingContextCallback painter, { Clip clipBehavior: Clip.antiAlias, ClipRRectLayer oldLayer })

Clip further painting using a rounded rectangle.

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.
  • clipRRect is the rounded-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 clipRRect applied. This function calls the painter synchronously.
  • clipBehavior controls how the path is clipped. null

Implementation

ClipRRectLayer pushClipRRect(bool needsCompositing, Offset offset, Rect bounds, RRect clipRRect, PaintingContextCallback painter, { Clip clipBehavior = Clip.antiAlias, ClipRRectLayer oldLayer }) {
  assert(clipBehavior != null);
  final Rect offsetBounds = bounds.shift(offset);
  final RRect offsetClipRRect = clipRRect.shift(offset);
  if (needsCompositing) {
    final ClipRRectLayer layer = oldLayer ?? ClipRRectLayer();
    layer
      ..clipRRect = offsetClipRRect
      ..clipBehavior = clipBehavior;
    pushLayer(layer, painter, offset, childPaintBounds: offsetBounds);
    return layer;
  } else {
    clipRRectAndPaint(offsetClipRRect, clipBehavior, offsetBounds, () => painter(this, offset));
    return null;
  }
}