of static method

OverlayState of(
  1. BuildContext context
)

Returns the OverlayState from the closest Overlay ancestor.

Throws a StateError if no Overlay ancestor is found.

Implementation

static OverlayState of(BuildContext context) {
  final state = maybeOf(context);
  if (state == null) {
    throw StateError(
      'Overlay.of() called with a context that does not contain an Overlay.',
    );
  }
  return state;
}