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()
// draw rect
..addRRect(RRect.fromRectAndRadius(
Rect.fromLTWH(0, 0, size.width, size.height),
Radius.circular(borderRadius!),
));
// draw small clip circles
final clipContainerSize = size.height - smallClipRadius!;
final smallClipSize = smallClipRadius! * 2;
final smallClipBoxSize = clipContainerSize / numberOfSmallClips!;
final smallClipPadding = (smallClipBoxSize - smallClipSize) / 2;
final smallClipStart = smallClipRadius! / 2;
final clipPath = Path();
List.generate(numberOfSmallClips!, (index) {
final boxX = smallClipStart + smallClipBoxSize * index;
final centerX = boxX + smallClipPadding + smallClipRadius!;
return Offset(0, centerX);
// ignore: avoid_function_literals_in_foreach_calls
}).forEach((centerOffset) {
clipPath.addOval(Rect.fromCircle(
center: centerOffset,
radius: smallClipRadius!,
));
});
// combine two path together
final ticketPath = Path.combine(
PathOperation.reverseDifference,
clipPath,
path,
);
return ticketPath;
}