showAppKitDialog<T> function
Future<T?>
showAppKitDialog<T>({
- required BuildContext context,
- required WidgetBuilder builder,
- bool barrierDismissible = false,
- Color? barrierColor,
- String? barrierLabel,
- RouteSettings? routeSettings,
Displays a macos alert dialog above the current contents of the app.
Implementation
Future<T?> showAppKitDialog<T>({
required BuildContext context,
required WidgetBuilder builder,
bool barrierDismissible = false,
Color? barrierColor,
String? barrierLabel,
bool useRootNavigator = true,
RouteSettings? routeSettings,
}) {
final provider = MainWindowStateListener.instance;
final initialData = Stream.value(provider.isMainWindow.value);
final stream = provider.isMainWindow;
// combine the two streams and return the first value
return Stream.fromFutures([initialData.first, stream.first])
.first
.then((data) {
if (!context.mounted) {
return null;
}
final navigator = Navigator.of(context, rootNavigator: useRootNavigator);
final theme = AppKitTheme.of(context);
return navigator.push<T>(
_AppKitDialogRoute<T>(
settings: routeSettings,
pageBuilder: (context, animation, secondaryAnimation) {
return Builder(
builder: (context) {
return builder(context);
},
);
},
capturedThemes: InheritedTheme.capture(
from: context,
// ignore: use_build_context_synchronously
to: navigator.context,
),
barrierDismissible: barrierDismissible,
barrierColor:
barrierColor ?? theme.controlBackgroundColor.multiplyOpacity(0.5),
barrierLabel: barrierLabel ??
MaterialLocalizations.of(context).modalBarrierDismissLabel,
),
);
});
}