yShowActionSheet function
void
yShowActionSheet(})
弹出actionsheet
Implementation
void yShowActionSheet(String message, List<String> actions, Function(int index, String action) onCallBack, {Function()? onCancel, BuildContext? context}) async {
final result = await showModalActionSheet<String>(
context: context ?? yPages.last.context,
actions: actions.map<SheetAction<String>>((e) => SheetAction(key: e, label: e)).toList(),
isDismissible: true,
useRootNavigator: true,
cancelLabel: "取消",
message: message,
title: "请选择",
);
var i = 0;
int? index;
for (var element in actions) {
if (element == result) index = i;
i++;
}
if (index != null && result != null) {
onCallBack(index, result);
} else {
onCancel?.call();
}
}