showListDialog method

YYDialog showListDialog(
  1. BuildContext context, {
  2. Color backgroundColor = Colors.white,
  3. BorderRadius borderRadius = const BorderRadius.only(topLeft: Radius.circular(4), topRight: Radius.circular(4)),
  4. bool isClickOutsideDismiss = false,
  5. List<ListItem> items = const <ListItem>[],
  6. ListItem? selectItem,
  7. OnListItemPressed? itemPressed,
  8. OnDialogBuildCall? buildCall,
  9. Gravity? gravity,
  10. double dx = 0,
  11. double dy = 0,
  12. OnDialogDismissCall? dismissCall,
  13. String? title,
  14. Color? titleColor,
  15. double? titleSize,
  16. Widget? submit,
  17. String? submitText,
  18. Color? submitTextColor,
  19. double? submitTextSize,
  20. BorderRadiusGeometry submitBorderRadius = const BorderRadius.all(Radius.circular(5)),
  21. Color? submitBackgroundColor,
  22. bool isPreSelect = false,
  23. bool isMultiSelect = false,
  24. String leastSelectHintText = "",
  25. Color? listSplitLineColor,
  26. EdgeInsetsGeometry? listSplitLineMargin = const EdgeInsets.only(left: 20, right: 20),
  27. double itemHeight = 52,
  28. Color? itemTextColor,
  29. double? itemTextSize,
  30. EdgeInsetsGeometry? itemPadding = const EdgeInsets.only(left: 20, right: 20),
  31. Widget? multiSelectIcon,
  32. Widget? multiUnSelectIcon,
  33. Widget? singleSelectIcon,
  34. Widget? singleUnSelectIcon,
})

显示列表样式dialog context widget context backgroundColor dialog背景颜色 borderRadius 边框圆角大小 isClickOutsideDismiss 点击dialog外部是否消失 itemPressed 列表元素单击监听 dx x方向上的偏移量 dy y方向上的偏移量 buildCall 构建完成回调 title 标题 submit 提交按钮 submitText 提交按钮文本 isPreSelect true-选择后需要由确认完成;false-选择直接完成;

Implementation

YYDialog showListDialog(
  BuildContext context, {
  Color backgroundColor = Colors.white,
  BorderRadius borderRadius = const BorderRadius.only(topLeft: Radius.circular(4), topRight: Radius.circular(4)),
  bool isClickOutsideDismiss = false,
  List<ListItem> items = const <ListItem>[],
  ListItem? selectItem,
  OnListItemPressed? itemPressed,
  OnDialogBuildCall? buildCall,
  Gravity? gravity,
  double dx = 0,
  double dy = 0,
  OnDialogDismissCall? dismissCall,
  String? title,
  Color? titleColor,
  double? titleSize,
  Widget? submit,
  String? submitText,
  Color? submitTextColor,
  double? submitTextSize,
  BorderRadiusGeometry submitBorderRadius = const BorderRadius.all(Radius.circular(5)),
  Color? submitBackgroundColor,
  bool isPreSelect = false,
  bool isMultiSelect = false,
  String leastSelectHintText = "",
  Color? listSplitLineColor,
  EdgeInsetsGeometry? listSplitLineMargin = const EdgeInsets.only(left: 20, right: 20),
  double itemHeight = 52,
  Color? itemTextColor,
  double? itemTextSize,
  EdgeInsetsGeometry? itemPadding = const EdgeInsets.only(left: 20, right: 20),
  Widget? multiSelectIcon,
  Widget? multiUnSelectIcon,
  Widget? singleSelectIcon,
  Widget? singleUnSelectIcon,
}) {
  if (selectItem != null) {
    for (var item in items) {
      if (item.value == selectItem.value) {
        item.check = true;
      } else {
        item.check = false;
      }
    }
  }
  var entry = DialogEntry();
  var dialogPanel = _ListDialogPanel(
    backgroundColor: backgroundColor,
    items: items,
    itemPressed: itemPressed,
    dialogEntry: entry,
    title: title,
    titleColor: titleColor,
    titleSize: titleSize,
    submit: submit,
    submitText: submitText,
    submitTextColor: submitTextColor,
    submitTextSize: submitTextSize,
    submitBorderRadius: submitBorderRadius,
    submitBackgroundColor: submitBackgroundColor,
    isPreSelect: isPreSelect,
    isMultiSelect: isMultiSelect,
    listSplitLineColor: listSplitLineColor,
    listSplitLineMargin: listSplitLineMargin,
    leastSelectHintText: leastSelectHintText,
    model: _ListDialogModel(),
    itemHeight: itemHeight,
    itemTextColor: itemTextColor,
    itemTextSize: itemTextSize,
    itemPadding: itemPadding,
    multiSelectIcon: multiSelectIcon,
    multiUnSelectIcon: multiUnSelectIcon,
    singleSelectIcon: singleSelectIcon,
    singleUnSelectIcon: singleUnSelectIcon,
    maxHeight: MediaQuery.of(context).size.height * 2 / 3,
  );
  var dialog = DialogPanel.showMessageDialog(
    context,
    container: dialogPanel,
    borderRadius: borderRadius,
    barrierDismissible: isClickOutsideDismiss,
    dismissCall: dismissCall,
    gravity: gravity,
    backgroundColor: backgroundColor,
    dx: dx,
    dy: dy,
  );
  entry.dialog = dialog;
  if (buildCall != null) {
    buildCall(dialog);
  }
  return dialog;
}