showActionSheet static method

void showActionSheet({
  1. Widget? title,
  2. Widget? content,
  3. List<Widget>? actions,
  4. Widget? cancel,
  5. VoidCallback? onCancel,
  6. ValueChanged<int>? onConfirm,
})

Implementation

static void showActionSheet({
  Widget? title,
  Widget? content,
  List<Widget>? actions,
  Widget? cancel,
  VoidCallback? onCancel,
  ValueChanged<int>? onConfirm,
}) {
  actions = actions ?? [];
  List<CupertinoActionSheetAction> actionsList = [];
  for (int i = 0; i < actions.length; i++) {
    actionsList.add(
      CupertinoActionSheetAction(
        onPressed: () => onConfirm?.call(i),
        child: actions[i],
      ),
    );
  }

  Get.bottomSheet(
    CupertinoActionSheet(
      title: title,
      message: content,
      actions: actionsList,
      cancelButton: CupertinoActionSheetAction(
        onPressed: () => onCancel != null ? onCancel.call() : Get.back(),
        child: cancel ?? Text('取消'.tr),
      ),
    ),
  );
}