getBounds method

Rect getBounds()

Implementation

Rect getBounds() {
  if (isEmpty) {
    return Rect.zero;
  }

  var left = first.left;
  var top = first.top;
  var right = first.right;
  var bottom = first.bottom;

  for (final rect in this) {
    if (rect.left < left) {
      left = rect.left;
    }

    if (rect.top < top) {
      top = rect.top;
    }

    if (rect.right > right) {
      right = rect.right;
    }

    if (rect.bottom > bottom) {
      bottom = rect.bottom;
    }
  }

  return Rect.fromLTRB(left, top, right, bottom);
}