showCustomDialog static method

void showCustomDialog({
  1. required BuildContext context,
  2. required Widget builder(
    1. BuildContext context
    ),
  3. String title = "",
  4. bool? barrierDismissible,
  5. bool? showCloseBtn,
  6. bool? autoScroll,
  7. double? containerMaxHeight,
  8. double? containerMaxWidth,
  9. EdgeInsets? containerPadding,
  10. double? contentMaxHeight,
  11. double? contentMaxWidth,
  12. Color? backgroundColor,
})

Implementation

static void showCustomDialog({
  required BuildContext context,
  required Widget Function(BuildContext context) builder,
  String title = "",
  bool? barrierDismissible,
  bool? showCloseBtn,
  bool? autoScroll,
  double? containerMaxHeight,
  double? containerMaxWidth,
  EdgeInsets? containerPadding,
  double? contentMaxHeight,
  double? contentMaxWidth,
  Color? backgroundColor,
}) {
   showDialog(
      context: context,
      barrierDismissible: barrierDismissible ?? true,
      builder: (c) {
        return Dialog(
            shape: const RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(10)),
            ),
            child: Container(
              decoration: BoxDecoration(
                  color: backgroundColor,
                  borderRadius: BorderRadius.circular(10)),
              constraints:  BoxConstraints(
                      maxHeight: containerMaxHeight ?? 604,
                      maxWidth: containerMaxWidth ?? 490),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Align(
                    alignment: Alignment.topRight,
                    child: MouseRegion(
                      cursor: SystemMouseCursors.click,
                      child: GestureDetector(
                        onTap: () {
                          if ((showCloseBtn ?? true)) {
                            Navigator.of(context).pop();
                          }
                        },
                        child: Container(
                          color: Colors.transparent,
                          padding: const EdgeInsets.all(10),
                          child: (showCloseBtn ?? true)
                              ? const Icon(
                                  Icons.close_outlined,
                                  size: 14,
                                  color: Color(0xff888888),
                                )
                              : null,
                        ),
                      ),
                    ),
                  ),
                  if (title.isNotEmpty)
                    Align(
                      alignment: Alignment.center,
                      child: Text(
                        title,
                        style: const TextStyle(
                            fontSize: 16, color: Color(0xff333333)),
                      ),
                    ),
                  Container(
                    padding: containerPadding ?? const EdgeInsets.all(20),
                    constraints: BoxConstraints(
                        maxHeight: contentMaxHeight ?? 520,
                        maxWidth: contentMaxWidth ?? 502),
                    child: builder(c),
                  )
                ],
              ),
            ));
      });
}