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();

  if (navBarAlignment == 'bottom') {
    path.lineTo(topLeft.dx, topLeft.dy);
    path.lineTo(curvePos, topLeft.dy);

    path.quadraticBezierTo(curveWidth * 0.15 + curvePos, 0,
        curveWidth * 0.2 + curvePos, curveHeight * 0.5);

    path.quadraticBezierTo(curveWidth * 0.3 + curvePos, curveHeight,
        curveWidth * 0.5 + curvePos, curveHeight);

    path.quadraticBezierTo(curveWidth * 0.7 + curvePos, curveHeight,
        curveWidth * 0.8 + curvePos, curveHeight * 0.5);

    path.quadraticBezierTo(
        curveWidth * 0.85 + curvePos, 0,
        curveWidth + curvePos, 0);

    path.lineTo(topRight.dx, topRight.dy);
    path.lineTo(bottomRight.dx, bottomRight.dy);
    path.lineTo(bottomLeft.dx, bottomLeft.dy);
  }
  else {
    path.lineTo(topLeft.dx, topLeft.dy);
    path.lineTo(curvePos, topLeft.dy);

    path.quadraticBezierTo(curveWidth * 0.15 + curvePos, navBarHeight,
        curveWidth * 0.2 + curvePos, navBarHeight - curveHeight * 0.5);

    path.quadraticBezierTo(
        curveWidth * 0.3 + curvePos,
        navBarHeight - curveHeight,
        curveWidth * 0.5 + curvePos,
        navBarHeight - curveHeight);

    path.quadraticBezierTo(
        curveWidth * 0.7 + curvePos,
        navBarHeight - curveHeight,
        curveWidth * 0.8 + curvePos,
        navBarHeight - curveHeight * 0.5);

    path.quadraticBezierTo(curveWidth * 0.85 + curvePos, navBarHeight,
        curveWidth + curvePos, navBarHeight);

    path.lineTo(topRight.dx, topRight.dy);
    path.lineTo(bottomRight.dx, bottomRight.dy);
    path.lineTo(bottomLeft.dx, bottomLeft.dy);
  }

  path.close();

  return path;
}