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) {
  // If there's padding, we need to create an inset path
  if (padding != EdgeInsets.zero) {
    // Calculate the inset size
    final insetSize = Size(
      size.width - padding.left - padding.right,
      size.height - padding.top - padding.bottom,
    );

    // Get the path for the inset size
    final insetPath = shape.buildPath(insetSize);

    // Translate the path by the padding offset
    return insetPath.shift(Offset(padding.left, padding.top));
  }

  // No padding, return the shape's path directly
  return shape.buildPath(size);
}