bounds property

Rect get bounds

获取边界矩形

Implementation

Rect get bounds {
  final points = vertices;
  double xMin = points[0].x;
  double xMax = points[0].x;
  double yMin = points[0].y;
  double yMax = points[0].y;

  for (int i = 1; i < points.length; i++) {
    final point = points[i];
    if (point.x > xMax) xMax = point.x;
    if (point.x < xMin) xMin = point.x;
    if (point.y > yMax) yMax = point.y;
    if (point.y < yMin) yMin = point.y;
  }

  return Rect.fromLTRB(xMin, yMin, xMax, yMax);
}