dialog<T> method
Show a dialog.
You can pass a transitionDuration
and/or transitionCurve
,
overriding the defaults when the dialog shows up and closes.
When the dialog closes, uses those animations in reverse.
Implementation
Future<T?> dialog<T>(
Widget widget, {
bool barrierDismissible = true,
Color? barrierColor,
bool useSafeArea = true,
GlobalKey<NavigatorState>? navigatorKey,
Object? arguments,
Duration? transitionDuration,
Curve? transitionCurve,
String? name,
RouteSettings? routeSettings,
}) {
assert(debugCheckHasMaterialLocalizations(context!));
// final theme = Theme.of(context, shadowThemeOnly: true);
final theme = Theme.of(context!);
if (arguments != null) {
routing.args = arguments;
}
return generalDialog<T>(
pageBuilder: (buildContext, animation, secondaryAnimation) {
final pageChild = widget;
Widget dialog = Builder(builder: (context) {
return Theme(data: theme, child: pageChild);
});
if (useSafeArea) {
dialog = SafeArea(child: dialog);
}
return dialog;
},
barrierDismissible: barrierDismissible,
barrierLabel: MaterialLocalizations.of(context!).modalBarrierDismissLabel,
barrierColor: barrierColor ?? Colors.black54,
transitionDuration: transitionDuration ?? defaultDialogTransitionDuration,
transitionBuilder: (context, animation, secondaryAnimation, child) {
return FadeTransition(
opacity: CurvedAnimation(
parent: animation,
curve: transitionCurve ?? defaultDialogTransitionCurve,
),
child: child,
);
},
navigatorKey: navigatorKey,
routeSettings:
routeSettings ?? RouteSettings(arguments: arguments, name: name),
);
}