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) {
  final path = Path();

  // Start at the top-left corner
  path.lineTo(0, size.height * 0.5);

  // Draw the first half-wave
  path.quadraticBezierTo(
    size.width * 0.25, size.height * 0.25, // Control point
    size.width * 0.5, size.height * 0.5, // End point
  );

  // Draw the second half-wave
  path.quadraticBezierTo(
    size.width * 0.75, size.height * 0.75, // Control point
    size.width, size.height * 0.5, // End point
  );

  // Complete the shape
  path.lineTo(size.width, 0);
  path.close();

  return path;
}