getBounds static method

Rect getBounds(
  1. List<Vector2> pts
)

Creates a Rect that represents the bounds of the list pts.

Implementation

static Rect getBounds(List<Vector2> pts) {
  final xPoints = pts.map((e) => e.x);
  final yPoints = pts.map((e) => e.y);

  final minX = xPoints.reduce(min);
  final maxX = xPoints.reduce(max);
  final minY = yPoints.reduce(min);
  final maxY = yPoints.reduce(max);
  return Rect.fromPoints(Offset(minX, minY), Offset(maxX, maxY));
}