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) {
  // This is where we decide what part of our image is going to be visible.
  var path = Path();
  path.lineTo(0.0, size.height);

  var firstControlPoint = new Offset(size.width / 7, size.height - 30);
  var firstEndPoint = new Offset(size.width / 6, size.height / 1.5);

  path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
      firstEndPoint.dx, firstEndPoint.dy);

  var secondControlPoint = Offset(size.width / 5, size.height / 4);
  var secondEndPoint = Offset(size.width / 1.5, size.height / 5);
  path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
      secondEndPoint.dx, secondEndPoint.dy);

  var thirdControlPoint =
  Offset(size.width - (size.width / 9), size.height / 6);
  var thirdEndPoint = Offset(size.width, 0.0);
  path.quadraticBezierTo(thirdControlPoint.dx, thirdControlPoint.dy,
      thirdEndPoint.dx, thirdEndPoint.dy);

  ///move from bottom right to top
  path.lineTo(size.width, 0.0);

  ///finally close the path by reaching start point from top right corner
  path.close();
  return path;
}