showDialogWithWidgets static method

void showDialogWithWidgets({
  1. Widget? title,
  2. Widget? message,
  3. Widget? buttonLabel,
  4. Function? onSubmit,
})

Implementation

static void showDialogWithWidgets(
    {Widget? title,
    Widget? message,
    Widget? buttonLabel,
    Function? onSubmit}) {
  Get.dialog(
    Dialog(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(16),
      ),
      child: Padding(
        padding: const EdgeInsets.all(24.0),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            if (title != null) ...[
              title,
              const SizedBox(height: 16),
            ],
            if (message != null) ...[
              message,
              const SizedBox(height: 24),
            ],
            if (buttonLabel != null) ...[
              ElevatedButton(
                onPressed: () {
                  Get.back();
                  onSubmit?.call();
                },
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.blue,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(12),
                  ),
                ),
                child: Padding(
                  padding: const EdgeInsets.symmetric(
                    horizontal: 24.0,
                    vertical: 12.0,
                  ),
                  child: buttonLabel,
                ),
              ),
            ],
          ],
        ),
      ),
    ),
  );
}