showActionSheet<T> static method
Future<T?>
showActionSheet<T>({
- Widget? title,
- Widget? content,
- List<
Widget> ? actions, - Widget? cancel,
- VoidCallback? onCancel,
- ValueChanged<
int> ? onConfirm,
显示底部操作表
Implementation
static Future<T?> showActionSheet<T>({
Widget? title,
Widget? content,
List<Widget>? actions,
Widget? cancel,
VoidCallback? onCancel,
ValueChanged<int>? onConfirm,
}) async {
final context = ComContext.context;
final actionsList = (actions ?? []).asMap().entries.map((entry) {
return CupertinoActionSheetAction(
onPressed: () {
if (onConfirm != null) {
onConfirm(entry.key);
}
Navigator.of(context).pop();
},
child: entry.value,
);
}).toList();
return await showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) => CupertinoActionSheet(
title: title,
message: content,
actions: actionsList,
cancelButton: CupertinoActionSheetAction(
onPressed: () {
if (onCancel != null) {
onCancel();
}
Navigator.of(context).pop();
},
child: cancel ?? Text(ComLocalizations.of(context).cancel),
),
),
);
}