showSingleButtonDialog static method

void showSingleButtonDialog(
  1. BuildContext context, {
  2. required String label,
  3. bool showIcon = false,
  4. Image? iconWidget,
  5. String? title,
  6. Widget? titleWidget,
  7. String? message,
  8. Widget? messageWidget,
  9. String? warning,
  10. Widget? warningWidget,
  11. Widget? labelWidget,
  12. GestureTapCallback? onTap,
  13. bool barrierDismissible = true,
  14. int titleMaxLines = cTitleMaxLines,
  15. DialogConfig? themeData,
})

展示底部只有一个按钮的对话框 对话框的点击回调是onTap label 底部按钮的文案 labelWidget 自定义底部按钮的显示

Implementation

static void showSingleButtonDialog(
  BuildContext context, {
  required String label,
  bool showIcon = false,
  Image? iconWidget,
  String? title,
  Widget? titleWidget,
  String? message,
  Widget? messageWidget,
  String? warning,
  Widget? warningWidget,
  Widget? labelWidget,
  GestureTapCallback? onTap,
  bool barrierDismissible = true,
  int titleMaxLines = cTitleMaxLines,
  DialogConfig? themeData,
}) {
  List<Widget> actionsWidget = [];

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