popupDialog<T> method
Future<T?>
popupDialog<
T>({
})
Implementation
Future<T?> popupDialog<T>({
/// 这个参数是一个方法,入参是 context,animation,secondaryAnimation,返回一个 Widget
RoutePageBuilder? builder,
/// GeneralDialog 配置
DialogOptions? options,
}) {
options = GlobalOptions().dialogOptions.merge(options);
RouteTransitionsBuilder? transitionBuilder;
if (options.fromStyle != PopupFromStyle.fromCenter) {
transitionBuilder = options.transitionBuilder ??
(__, Animation<double> animation, _, Widget child) {
late Offset translation;
switch (options!.fromStyle) {
case PopupFromStyle.fromLeft:
translation = Offset(animation.value - 1, 0);
break;
case PopupFromStyle.fromRight:
translation = Offset(1 - animation.value, 0);
break;
case PopupFromStyle.fromTop:
translation = Offset(0, animation.value - 1);
break;
case PopupFromStyle.fromBottom:
translation = Offset(0, 1 - animation.value);
break;
case PopupFromStyle.fromCenter:
translation = const Offset(0, 0);
break;
}
return FractionalTranslation(
translation: translation, child: child);
};
}
return showGeneralDialog(
context: GlobalOptions().globalNavigatorKey.currentContext!,
pageBuilder: builder ?? (_, Animation<double> animation, __) => this,
barrierDismissible: options.barrierDismissible,
barrierLabel: options.barrierLabel,
barrierColor: options.barrierColor,
transitionDuration: options.transitionDuration,
transitionBuilder: transitionBuilder,
useRootNavigator: options.useRootNavigator,
routeSettings: options.routeSettings,
anchorPoint: options.anchorPoint);
}