getClip method

  1. @override
Path getClip(
  1. Size size
)
override

Returns a description of the clip given that the render object being clipped is of the given size.

Implementation

@override
Path getClip(Size size) {
  var pathRect = Rect.fromCenter(
    center: size.center(Offset.zero),
    width: clipSize.width,
    height: clipSize.height,
  );

  Path path = Path();
  if (shape == ClipShape.circle) {
    path.addOval(pathRect);
  } else if (shape == ClipShape.rrect) {
    path.addRRect(
      ui.RRect.fromRectAndRadius(
        pathRect,
        rrectRadius ?? const Radius.circular(10),
      ),
    );
  } else if (shape == ClipShape.rect) {
    path.addRect(pathRect);
  }
  path.close();
  return Path.combine(
    PathOperation.difference,
    Path()..addRect(Rect.fromLTWH(0, 0, size.width, size.height)),
    path,
  );
}