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 h = size.height;
  var w = size.width;
  position = position + (radius * 0.25);
  final path = Path();

  // Top or Vertical or All
  path.moveTo(0, 0);
  path.lineTo(position - radius, 0.0);
  if (edge == Edge.top || edge == Edge.vertical || edge == Edge.all) {
    path.arcToPoint(
      Offset(position, 0),
      clockwise: false,
      radius: const Radius.circular(1),
    );
  }

  // Right or Horizontal or All
  path.lineTo(w, 0.0);
  path.lineTo(w, position - radius);
  if (edge == Edge.right || edge == Edge.horizontal || edge == Edge.all) {
    path.arcToPoint(
      Offset(w, position),
      clockwise: false,
      radius: const Radius.circular(1),
    );
  }

  // Bottom or Vertical or All
  path.lineTo(w, h);
  path.lineTo(position, h);
  if (edge == Edge.bottom || edge == Edge.vertical || edge == Edge.all) {
    path.arcToPoint(
      Offset(position - radius, h),
      clockwise: false,
      radius: const Radius.circular(1),
    );
  }

  // Left or Horizontal or All
  path.lineTo(0.0, h);
  path.lineTo(0, position);
  if (edge == Edge.left || edge == Edge.horizontal || edge == Edge.all) {
    path.arcToPoint(
      Offset(0, position - radius),
      clockwise: false,
      radius: const Radius.circular(1),
    );
  }
  path.close();
  return path;
}