show static method

void show({
  1. required BuildContext context,
  2. required String title,
  3. Widget? content,
  4. List<Widget>? actions,
  5. bool barrierDismissible = false,
  6. EdgeInsets? paddingAll,
  7. EdgeInsets? padding,
  8. Widget? icon,
  9. double? width,
  10. BorderRadiusGeometry? borderRadius,
  11. Color? dividerColor,
})

Displays a customizable dialog.

  • context (required): The BuildContext to show the dialog from.
  • title (required): Title text shown in the header.
  • content: Optional body widget shown below the title.
  • actions: Optional list of buttons shown in the footer.
  • barrierDismissible: Tap-outside-to-close. Defaults to false.
  • paddingAll: Padding for the header and content sections. Defaults to EdgeInsets.all(16).
  • padding: Padding for the actions footer. Defaults to EdgeInsets.symmetric(horizontal: 20, vertical: 16).
  • icon: Optional leading icon shown before the title.
  • width: Dialog width. Defaults to 400.
  • borderRadius: Dialog corner radius. Defaults to Radius.circular(12).
  • dividerColor: Color of the dividers. Defaults to Colors.grey.

Implementation

static void show({
  required BuildContext context,
  required String title,
  Widget? content,
  List<Widget>? actions,
  bool barrierDismissible = false,
  EdgeInsets? paddingAll,
  EdgeInsets? padding,
  Widget? icon,
  double? width,
  BorderRadiusGeometry? borderRadius,
  Color? dividerColor,
}) {
  showDialog(
    barrierDismissible: barrierDismissible,
    context: context,
    builder: (_) {
      return Dialog(
        shape: RoundedRectangleBorder(
          borderRadius:
              borderRadius ?? const BorderRadius.all(Radius.circular(12)),
        ),
        clipBehavior: Clip.antiAliasWithSaveLayer,
        child: SizedBox(
          width: width ?? 400,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              // Header
              Padding(
                padding: paddingAll ?? const EdgeInsets.all(16),
                child: Row(
                  children: [
                    if (icon != null) ...[
                      icon,
                      const SizedBox(width: 8),
                    ],
                    Expanded(
                      child: Text(
                        title,
                        style: const TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ),
                    InkWell(
                      onTap: () => Navigator.pop(context),
                      child: Icon(
                        Icons.close,
                        size: 20,
                        color: Colors.black.withValues(alpha: 0.5),
                      ),
                    ),
                  ],
                ),
              ),

              // Content
              if (content != null) ...[
                Divider(
                    height: 0,
                    thickness: 1,
                    color: dividerColor ?? Colors.grey),
                Padding(
                  padding: paddingAll ?? const EdgeInsets.all(16),
                  child: content,
                ),
              ],

              // Actions
              if (actions != null) ...[
                Divider(
                    height: 0,
                    thickness: 1,
                    color: dividerColor ?? Colors.grey),
                Padding(
                  padding: padding ??
                      const EdgeInsets.symmetric(
                          horizontal: 20, vertical: 16),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: actions,
                  ),
                ),
              ],
            ],
          ),
        ),
      );
    },
  );
}