childBoundaryRect property

  1. @protected
Rect? get childBoundaryRect

The _boundaryRect is calculated by adding the boundaryMargin to the size of the child.

Implementation

@protected
Rect? get childBoundaryRect {
  assert(childKey.currentContext != null);

  Size childSize;
  Size? realChildSize = this.realChildSize;
  if (realChildSize != null) {
    childSize = realChildSize;
  } else if (_cachedChildSize != null) {
    return _cachedChildBoundaryRect;
  } else {
    final context = childKey.currentContext;
    if (context == null) {
      return _cachedChildBoundaryRect;
    }
    //Why isn't there a better way to get the size of a widget that may be inactive?
    final RenderObject? renderObject = (context as Element).renderObject;
    if (renderObject is! RenderBox ||
        !renderObject.hasSize ||
        !renderObject.attached) {
      return _cachedChildBoundaryRect;
    }
    _cachedChildSize = renderObject.size;
    return _cachedChildBoundaryRect;
  }
  return Offset.zero & childSize;
}