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) {
  var path = Path();

  switch (position) {
    case BannerPosition.topRight:
      path.moveTo(0, 0);
      path.lineTo(contentRatio / math.sqrt2 * size.width, 0);
      path.lineTo(
          size.width, (1 - (contentRatio / math.sqrt2)) * size.height);
      path.lineTo(size.width, size.height);
      break;
    case BannerPosition.topLeft:
      path.moveTo(size.width, 0);
      path.lineTo((1 - (contentRatio / math.sqrt2)) * size.width, 0);
      path.lineTo(0, (1 - (contentRatio / math.sqrt2)) * size.height);
      path.lineTo(0, size.height);
      break;
    case BannerPosition.bottomLeft:
      path.moveTo(0, 0);
      path.lineTo(size.width, size.height);
      path.lineTo(
          size.width * (1 - (contentRatio / math.sqrt2)), size.height);
      path.lineTo(0, size.height * (contentRatio / math.sqrt2));
      break;
    case BannerPosition.bottomRight:
      path.moveTo(size.width, 0);
      path.lineTo(size.width, size.height * (contentRatio / math.sqrt2));
      path.lineTo(size.width * (contentRatio / math.sqrt2), size.height);
      path.lineTo(0, size.height);
      break;
  }

  return path;
}