maskGeometryFromGlobalKey function
Measures the widget behind globalKey in the root coordinate space.
Scrollables keep items laid out slightly outside the viewport (cacheExtent) and clip them while painting. The raw paint bounds of such an item therefore land on content next to the list; a half-scrolled item spills over the list edge. MaskGeometry.clip carries the clip that paint applies, so callers can mask exactly what is visible and drop rects that are fully clipped.
Returns null when the widget is not laid out / attached, or when an ancestor is offstage (laid out but not painted). Navigator builds a pushed route offstage for its first frame when a HeroController is installed (MaterialApp does that), with the route already at its final position.
Implementation
MaskGeometry? maskGeometryFromGlobalKey(GlobalKey globalKey) {
return maskGeometryOf(globalKey.currentContext?.findRenderObject());
}