boundsFor function

UiBounds? boundsFor(
  1. Element element
)

Implementation

UiBounds? boundsFor(Element element) {
  final renderObject = element.renderObject;
  if (renderObject is! RenderBox ||
      !renderObject.hasSize ||
      renderObject.size.isEmpty) {
    return null;
  }
  final topLeft = renderObject.localToGlobal(Offset.zero);
  final rect = topLeft & renderObject.size;
  if (!rect.isFinite || rect.isEmpty) return null;
  return UiBounds(
    left: rect.left,
    top: rect.top,
    width: rect.width,
    height: rect.height,
  );
}