boundingBox property

  1. @override
Rectangle get boundingBox
override

The smallest axis-aligned rectangle that completely encloses the shape.

Implementation

@override
Rectangle get boundingBox {
  final minX = math.min(p1.x, p2.x).toDouble();
  final maxX = math.max(p1.x, p2.x).toDouble();
  final minY = math.min(p1.y, p2.y).toDouble();
  final maxY = math.max(p1.y, p2.y).toDouble();
  return Rectangle(
    width: maxX - minX,
    height: maxY - minY,
    center: Point(x: (minX + maxX) / 2, y: (minY + maxY) / 2)
  );
}