bounds property

  1. @override
Rectangle<num> bounds
override

Returns a rectangle that defines the area of this display object in this display object's local coordinates.

Implementation

@override
Rectangle<num> get bounds {
  if (_children.isEmpty) return super.bounds;

  num left = double.infinity;
  num top = double.infinity;
  num right = double.negativeInfinity;
  num bottom = double.negativeInfinity;

  for (var i = 0; i < _children.length; i++) {
    final rectangle = _children[i].boundsTransformed;

    if (rectangle.left < left) left = rectangle.left;
    if (rectangle.top < top) top = rectangle.top;
    if (rectangle.right > right) right = rectangle.right;
    if (rectangle.bottom > bottom) bottom = rectangle.bottom;
  }

  return Rectangle<num>(left, top, right - left, bottom - top);
}