maybeMorphAnchorRect function
- BuildContext context
Like morphAnchorRect, but null when the context has no laid-out box - for callers that can fall back (a centered dialog instead of an anchored popover) rather than crash.
Implementation
Rect? maybeMorphAnchorRect(BuildContext context) {
if (!context.mounted) {
return null;
}
final RenderObject? render = context.findRenderObject();
if (render is! RenderBox || !render.attached || !render.hasSize) {
return null;
}
final RenderObject? overlay = Overlay.maybeOf(
context,
)?.context.findRenderObject();
return render.localToGlobal(
Offset.zero,
ancestor: overlay is RenderBox ? overlay : null,
) &
render.size;
}