maybeOf static method
- BuildContext context, {
- bool rootOverlay = false,
The OverlayState from the closest instance of Overlay that encloses the given context within the closest LookupBoundary, if any.
Typical usage is as follows:
OverlayState? overlay = Overlay.maybeOf(context);
If rootOverlay is set to true, the state from the furthest instance of
this class is given instead. Useful for installing overlay entries above
all subsequent instances of Overlay.
See also:
- Overlay.of for a similar function that returns a non-nullable result and throws if an Overlay is not found.
Implementation
static OverlayState? maybeOf(BuildContext context, {bool rootOverlay = false}) {
return _RenderTheaterMarker.maybeOf(
context,
targetRootOverlay: rootOverlay,
createDependency: false,
)?.overlayEntryWidgetState.widget.overlayState;
}