showConfirmDialog static method

void showConfirmDialog(
  1. BuildContext context, {
  2. required String cancel,
  3. required String confirm,
  4. bool showIcon = false,
  5. Image? iconWidget,
  6. String? title,
  7. Widget? titleWidget,
  8. String? message,
  9. Widget? messageWidget,
  10. String? warning,
  11. Widget? warningWidget,
  12. Widget? cancelWidget,
  13. Widget? conformWidget,
  14. GestureTapCallback? onCancel,
  15. GestureTapCallback? onConfirm,
  16. bool barrierDismissible = true,
  17. int titleMaxLines = cTitleMaxLines,
  18. DialogConfig? themeData,
})

展示底部有两个按钮的弹窗 左侧是cancel 右侧是confirm cancel 左侧显示的文案 confirm 右侧显示的文案 cancelWidget 自定义显示的左侧 conformWidget 自定义显示的右侧

Implementation

static void showConfirmDialog(
  BuildContext context, {
  required String cancel,
  required String confirm,
  bool showIcon = false,
  Image? iconWidget,
  String? title,
  Widget? titleWidget,
  String? message,
  Widget? messageWidget,
  String? warning,
  Widget? warningWidget,
  Widget? cancelWidget,
  Widget? conformWidget,
  GestureTapCallback? onCancel,
  GestureTapCallback? onConfirm,
  bool barrierDismissible = true,
  int titleMaxLines = cTitleMaxLines,
  DialogConfig? themeData,
}) {
  List<Widget> actionsWidget = [];

  if (cancelWidget != null) {
    actionsWidget.add(cancelWidget);
  }
  if (conformWidget != null) {
    actionsWidget.add(conformWidget);
  }
  showDialog<void>(
    context: context,
    barrierDismissible: barrierDismissible,
    builder: (BuildContext dialogContext) {
      return PhoenixDialog(
        iconImage: iconWidget,
        showIcon: showIcon,
        titleText: title,
        titleWidget: titleWidget,
        messageText: message,
        contentWidget: messageWidget,
        warningWidget: warningWidget,
        warningText: warning,
        themeData: themeData,
        titleMaxLines: titleMaxLines,
        actionsText: [cancel, confirm],
        actionsWidget: actionsWidget,
        indexedActionCallback: (index) {
          if (index == 0) {
            if (onCancel != null) {
              onCancel();
            }
          }
          if (index == 1) {
            if (onConfirm != null) {
              onConfirm();
            }
          }
        },
      );
    },
  );
}