showDialog method

YYDialog showDialog(
  1. BuildContext context, {
  2. Color backgroundColor = Colors.white,
  3. Color barrierColor = const Color(0x4d000000),
  4. BorderRadius borderRadius = const BorderRadius.all(Radius.circular(6)),
  5. String title = '',
  6. AlignmentGeometry? titleAlignment,
  7. String message = '',
  8. Widget? contentView,
  9. List<ButtonArgs> buttonArgs = const <ButtonArgs>[],
  10. OnButtonPressed? buttonPressed,
  11. bool isClickOutsideDismiss = false,
  12. OnDialogBuildCall? buildCall,
  13. EdgeInsetsGeometry? padding,
  14. Gravity? gravity,
  15. bool isShowClose = false,
  16. AlignmentGeometry alignment = Alignment.center,
  17. Color contentColor = const Color(0xe63B372C),
  18. double contentFontSize = 16,
  19. dynamic margin = const EdgeInsets.only(left: 20, right: 20),
  20. OnDialogDismissCall? dismissCall,
  21. bool isKeyboardAvoiding = false,
  22. Color dividerColor = const Color(0xffefefef),
  23. bool isAutoClose = true,
})

显示dialog(message优先级大于contentView) context widget context backgroundColor dialog背景颜色 barrierColor dialog弹窗外背景 borderRadius 边框圆角大小 title 标题 titleAlignment 标题对齐方式 alignment 对齐方式 message 消息内容与contentView互斥,若设置message后contentView无效 contentView 内容自定义视图与message互斥 buttonArgs 按钮列表 buttonPressed 按钮事件回调 isClickOutsideDismiss 点击dialog外部是否消失 margin dialog外边距 buildCall 构建完成回调 KeyboardAvoiding true弹出dialog在软键盘之上 isAutoClose 是否自动关闭dialog,true-点击按钮时自动关闭dialog

Implementation

YYDialog showDialog(
  BuildContext context, {
  Color backgroundColor = Colors.white,
  Color barrierColor = const Color(0x4d000000),
  BorderRadius borderRadius = const BorderRadius.all(Radius.circular(6)),
  String title = '',
  AlignmentGeometry? titleAlignment,
  String message = '',
  Widget? contentView,
  List<ButtonArgs> buttonArgs = const <ButtonArgs>[],
  OnButtonPressed? buttonPressed,
  bool isClickOutsideDismiss = false,
  OnDialogBuildCall? buildCall,
  EdgeInsetsGeometry? padding,
  Gravity? gravity,
  bool isShowClose = false,
  AlignmentGeometry alignment = Alignment.center,
  Color contentColor = const Color(0xe63B372C),
  double contentFontSize = 16,
  margin = const EdgeInsets.only(left: 20, right: 20),
  OnDialogDismissCall? dismissCall,
  bool isKeyboardAvoiding = false,
  Color dividerColor = const Color(0xffefefef),
  bool isAutoClose = true,
}) {
  var entry = DialogEntry();
  var dialogPanel = _MessageDialogPanel(
    backgroundColor: backgroundColor,
    title: title,
    titleAlignment: titleAlignment,
    message: message,
    contentView: contentView,
    buttonArgs: buttonArgs,
    buttonPressed: buttonPressed,
    dialogEntry: entry,
    alignment: alignment,
    contentColor: contentColor,
    contentFontSize: contentFontSize,
    padding: padding ?? EdgeInsets.only(left: 20, top: title.isEmptyString ? 25 : 16, right: 20, bottom: 25),
    isShowClose: isShowClose,
    dividerColor: dividerColor,
    isAutoClose: isAutoClose,
  );
  var dialog = DialogPanel.showMessageDialog(
    context,
    container: dialogPanel,
    borderRadius: borderRadius,
    barrierDismissible: isClickOutsideDismiss,
    dismissCall: dismissCall,
    gravity: gravity,
    margin: margin,
    isKeyboardAvoiding: isKeyboardAvoiding,
    backgroundColor: backgroundColor,
    barrierColor: barrierColor,
  );
  entry.dialog = dialog;
  if (buildCall != null) {
    buildCall(dialog);
  }
  return dialog;
}