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
getClip(Size size) {
  final path = Path();
  double y = randomStep;
  while (y < size.height) {
    final yRandom = randomStep;
    double x = randomStep;

    while (x < size.width) {
      final xRandom = randomStep;
      path.addRect(
        Rect.fromPoints(
          Offset(x, y.toDouble()),
          Offset(x + xRandom, y + yRandom),
        ),
      );
      x += randomStep * 2;
    }
    y += yRandom;
  }

  path.close();
  return path;
}