show<T> method
Future<T?>
show<T>(
- BuildContext context,
- OverlayConfiguration<
T> configuration, { - bool adaptive = true,
Shows an overlay using the given configuration, anchored to context.
If an overlay managed by this controller is already open with a
configuration of the exact same runtime type as configuration, it's
updated in place via OverlayCompleter.config (see class docs);
otherwise it's closed and the new configuration is opened fresh.
adaptive is forwarded to OverlayConfiguration.adaptiveConversion.
Implementation
Future<T?> show<T>(
BuildContext context,
OverlayConfiguration<T> configuration, {
bool adaptive = true,
}) {
final resolved =
adaptive ? configuration.adaptiveConversion(context) : configuration;
final currentCompleter = _completer;
final currentConfig = _config;
if (currentCompleter != null &&
!currentCompleter.isCompleted &&
currentConfig != null &&
resolved.runtimeType == currentConfig.runtimeType) {
currentCompleter.config = resolved;
_config = resolved;
notifyListeners();
return currentCompleter.future as Future<T?>;
}
close();
final completer = resolved.show(context);
_completer = completer;
_config = resolved;
notifyListeners();
completer.future.whenComplete(() {
if (identical(_completer, completer)) {
_completer = null;
_config = null;
if (!_disposed) {
notifyListeners();
}
}
});
return completer.future;
}