yShowSelectBuilder function
void
yShowSelectBuilder(})
弹出单选框
Implementation
void yShowSelectBuilder(String message, bool cancelAble, List<String> actions, Function(int index, String action) onCallBack, {Function()? onCancelBack, BuildContext? context}) async {
final result = await showConfirmationDialog(
context: context ?? yPages.last.context,
message: message,
title: "请选择",
cancelLabel: cancelAble ? "取消" : null,
actions: actions.map<AlertDialogAction<String>>((e) => AlertDialogAction(key: e, label: e)).toList(),
useRootNavigator: true,
barrierDismissible: false,
okLabel: "确定",
);
var i = 0;
int? index;
for (var element in actions) {
if (element == result) index = i;
i++;
}
if (index == null) {
onCancelBack?.call();
return;
}
onCallBack(index!, result!);
}