showCenter<T> static method

Future<T?> showCenter<T>(
  1. Widget child, {
  2. bool dismissOnTouch = true,
  3. bool dismissOnBackPressed = true,
  4. Color? bgColor,
  5. double? radius,
  6. double width = 340,
  7. EdgeInsets? padding,
  8. bool fullscreen = false,
  9. Color? shadowColor,
})

shadowColor 整个对话框的背景色,会铺面整个屏幕,包括状态栏、导航栏 bgColor 对话框内部容器的背景色

Implementation

static Future<T?> showCenter<T>(Widget child, {bool dismissOnTouch = true,
      bool dismissOnBackPressed = true, Color? bgColor, double? radius, double width = 340,
      EdgeInsets? padding, bool fullscreen = false, Color? shadowColor,}) async {
  return await showDialog<T>(
    context: Get.context!,
    barrierColor: shadowColor,
    barrierDismissible: dismissOnTouch,
    builder: (context) => PopScope(
        canPop: dismissOnBackPressed,
        child: fullscreen ?
            Dialog.fullscreen(backgroundColor: bgColor ?? Theme.of(context).dialogBackgroundColor,
            child: child,)
            : Dialog(
          insetPadding: padding,
          clipBehavior: Clip.antiAlias,
          surfaceTintColor: Colors.transparent,
          shadowColor: Colors.transparent,
          backgroundColor: bgColor ?? Theme.of(context).dialogBackgroundColor,
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius ?? 10)),
          child: child,)),
  );
}