boundsOf function
Bounding box of points:
Rect.fromLTRB(leftmostX, topmostY, rightmostX, bottommostY). Non-empty.
Implementation
Rect boundsOf(List<Offset> points) {
var left = points.first.dx, top = points.first.dy;
var right = points.first.dx, bottom = points.first.dy;
for (final p in points) {
if (p.dx < left) left = p.dx;
if (p.dx > right) right = p.dx;
if (p.dy < top) top = p.dy;
if (p.dy > bottom) bottom = p.dy;
}
return Rect.fromLTRB(left, top, right, bottom);
}