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.addRect(Rect.fromLTWH(0, 0, (size.width - 310), size.height));

  // Crea un rectángulo que se recorta en el centro
  // path.addRect(
  //     Rect.fromLTWH(0, 0, (size.width - 310), size.height)); // Área completa
  // path.addRect(
  //     Rect.fromLTWH(size.width - 50, 0, (size.width - 310), size.height));
  // path.addRect(Rect.fromLTWH(0, size.width * 1.55, 500, 200));
  // path.addRect(const Rect.fromLTWH(70, 0, 310, 180));
  path.addRect(Rect.fromLTWH(0, 0, size.width, size.height));

// Rectángulo interior (que se restará del rectángulo exterior)
  double centerWidth = 300; // Ancho del rectángulo del centro 275
  double centerHeight = 440; // Alto del rectángulo del centro

  double borderRadius = 10;

// Calcular las coordenadas para centrar el rectángulo interior
  double left = (size.width - centerWidth) / 2;
  double top = (size.height - centerHeight) / 2;

// Crear el rectángulo interior y restarlo usando `Path.combine`
  // Path innerPath = Path()
  //   ..addRect(Rect.fromLTWH(left, top, centerWidth, centerHeight));

  // Crear un RRect (rectángulo con bordes redondeados) para el recorte
  Path innerPath = Path()
    ..addRRect(RRect.fromRectAndRadius(
      Rect.fromLTWH(left, top, centerWidth, centerHeight),
      Radius.circular(borderRadius),
    ));
  return Path.combine(
      PathOperation.difference, path, innerPath); // Define la diferencia
}