getClip method
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();
final width = size.width;
final height = size.height;
double curveRadius = 38.0 * animation;
const elevationFromEdge = 2.0;
path.moveTo(0, elevationFromEdge);
int items = NavbarNotifier.length;
double iconSize = 24.0;
double padding = (width - (iconSize * items)) / (items);
double centerX =
(index) * padding + (index) * iconSize + iconSize / 2 + padding / 2;
Offset point1 = Offset(centerX - curveRadius - 20, 0);
path.lineTo(point1.dx - 40, point1.dy);
point1 = Offset(point1.dx + 20, -8);
Offset point2 = Offset(point1.dx, 20);
path.quadraticBezierTo(point1.dx, point1.dy, point2.dx, point2.dy);
Offset point3 = Offset(centerX + curveRadius, 20);
path.arcToPoint(point3,
radius: const Radius.circular(10), clockwise: false);
Offset point4 = Offset(point3.dx, -8);
Offset point5 = Offset(point4.dx + 40, 0);
path.quadraticBezierTo(point4.dx, point4.dy, point5.dx, point5.dy);
// center point of the notch curve
path.lineTo(width, elevationFromEdge);
path.lineTo(width, height);
path.lineTo(0, height);
path.close();
// rectangle clip
return path;
}