of static method
Retrieves the closest enclosing OverlayState from the given context.
Implementation
static OverlayState? of(BuildContext context) {
Element? current = context as Element?;
while (current != null) {
if (current is StatefulElement && current.state is OverlayState) {
return current.state as OverlayState;
}
current = current.parent;
}
return null;
}