measureTarget function
RN measureInstance() — measures a target's on-screen rect. Returns null
if the widget is unmounted or has no size yet.
Implementation
MeasuredRect? measureTarget(GlobalKey key) {
final context = key.currentContext;
if (context == null) return null;
final object = context.findRenderObject();
if (object is! RenderBox || !object.hasSize) return null;
final size = object.size;
if (size.width <= 0 || size.height <= 0) return null;
final origin = object.localToGlobal(Offset.zero);
return MeasuredRect(
x: origin.dx,
y: origin.dy,
width: size.width,
height: size.height,
);
}