showOverlay<T> function

OverlayCompleter<T?> showOverlay<T>(
  1. BuildContext context,
  2. OverlayConfiguration<T> configuration, {
  3. bool adaptive = true,
})

Unified entry point for presenting any OverlayConfiguration.

Replaces directly calling showPopover/openDrawer/openSheet/showDialog or reaching for a specific OverlayHandler. When adaptive is true (the default), configuration is first passed through OverlayConfiguration.adaptiveConversion so it can present itself differently depending on platform (e.g. a popover becoming a bottom drawer on mobile), explicitly, per call site, instead of via a single app-wide default.

Example:

showOverlay(
  context,
  PopoverConfiguration(
    alignment: Alignment.topCenter,
    builder: (context) => const Text('Popover content'),
  ),
  adaptive: false, // force a popover even on mobile
);

Implementation

OverlayCompleter<T?> showOverlay<T>(
  BuildContext context,
  OverlayConfiguration<T> configuration, {
  bool adaptive = true,
}) {
  final resolved =
      adaptive ? configuration.adaptiveConversion(context) : configuration;
  return resolved.show(context);
}