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 = Path()
    ..addRRect(RRect.fromRectAndRadius(
      Rect.fromLTWH(0, 0, size.width, size.height),
      Radius.circular(borderRadius),
    ));

  final double left = paddingLeft;
  final double top = paddingVertical;
  final double right = size.width - paddingRight;
  final double bottom = size.height - paddingVertical;

  // Cut out the transparent center
  path.addRRect(RRect.fromRectAndRadius(
    Rect.fromLTRB(left, top, right, bottom),
    Radius.circular(borderRadius),
  ));

  return path..fillType = PathFillType.evenOdd;
}