of static method

OverlayState? of(
  1. BuildContext context
)

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;
}