overlayViewportWidthOf function
The viewport width a surface drawn in context's root overlay should scale
against: the overlay's own laid-out width, corrected as
layoutMediaQueryData does, or MediaQuery width before it has a size.
For content that is not itself full screen (a tooltip) but sizes against the screen it floats over.
Implementation
double overlayViewportWidthOf(BuildContext context) {
final media = MediaQuery.of(context);
final overlayBox =
Overlay.maybeOf(context, rootOverlay: true)?.context.findRenderObject();
if (overlayBox is! RenderBox || !overlayBox.hasSize) return media.size.width;
return layoutMediaQueryData(media, overlayBox.size).size.width;
}