showMCupertinoDialog function

dynamic showMCupertinoDialog({
  1. Color titleColor = Colors.black,
  2. required BuildContext context,
  3. required Widget child,
  4. String? title,
  5. Widget? topTitle,
  6. bool showExit = false,
  7. Function? onTap,
  8. BorderRadiusGeometry? borderRadius,
  9. EdgeInsetsGeometry? margin,
  10. Gradient? gradient,
  11. Color? backgroundColor = Colors.white,
  12. TextStyle? titleStyle,
})

Implementation

showMCupertinoDialog({
  Color titleColor = Colors.black,
  required BuildContext context,
  required Widget child,
  String? title,
  Widget? topTitle,
  bool showExit = false,
  Function? onTap,
  BorderRadiusGeometry? borderRadius,
  EdgeInsetsGeometry? margin,
  Gradient? gradient,
  Color? backgroundColor = Colors.white,
  TextStyle? titleStyle,
}) {
  return showCupertinoDialog(
    context: context,
    builder: (context) {
      return Material(
        type: MaterialType.transparency,
        child: Container(
          color: Colors.white12,
          child: BackdropFilter(
            filter: ImageFilter.blur(sigmaX: 8.0, sigmaY: 8.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                GestureDetector(
                  onTap: () {},
                  child: Container(
                    margin: margin ?? const EdgeInsets.all(24.0),
                    decoration: BoxDecoration(
                      color: gradient == null ? backgroundColor : null,
                      gradient: gradient,
                      borderRadius: borderRadius ?? BorderRadius.circular(50.0),
                    ),
                    child: Column(
                      children: [
                        if (topTitle != null) topTitle,
                        Stack(
                          children: [
                            Align(
                              child: Column(
                                children: [
                                  if (title != null)
                                    MText(
                                      text: title,
                                      size: FoontSize.font22,
                                      weight: FontWeight.w800,
                                      color: titleColor,
                                      style: titleStyle,
                                    ).addPadding(
                                      bottom: 30.0,
                                      top: topTitle != null ? 0 : 21.0,
                                    ),
                                  child
                                ],
                              ).addPadding(top: 12.0),
                            ),
                            if (showExit)
                              const Align(
                                alignment: AlignmentDirectional.topEnd,
                                child: MSvg(
                                  name: Svgs.exit,
                                  height: 35.0,
                                  width: 35.0,
                                ),
                              ).addAction(
                                padding: MPadding.set(
                                  all: topTitle != null ? 0 : 24.0,
                                  horizontal: topTitle != null ? 24.0 : 0,
                                ),
                                onGesture: () {
                                  context.pop();
                                },
                              ),
                          ],
                        ),
                      ],
                    ),
                  ),
                )
              ],
            ).addAction(onGesture: onTap ?? () => context.pop()),
          ),
        ),
      );
    },
  );
}