showListDialog method
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,
显示列表样式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;
}