showActionSheet static method

Future showActionSheet(
  1. ValueChanged<String> callBack, {
  2. bool crop = false,
  3. List<Widget>? actions,
  4. Widget? cancel,
})

Implementation

static Future showActionSheet(ValueChanged<String> callBack,
    {bool crop = false, List<Widget>? actions, Widget? cancel}) async {
  CommonHelper.showActionSheet(
      actions: actions ?? [Text("相册选择".tr), Text("拍摄照片".tr)],
      cancel: cancel,
      onConfirm: (val) async {
        // List<Permission> permissionList = [
        //   Permission.storage,
        //   Permission.camera
        // ];
        // final permissions =
        //     await PermissionUtil.checkPermission([permissionList[val]]);
        // if (!permissions) {
        //   return CommonHelper.showToast('请开启相关权限'.tr);
        // }
        dynamic img;
        if (val == 0) {
          img = await pickImage(source: ImageSource.gallery, crop: crop);
        } else {
          img = await pickImage(source: ImageSource.camera, crop: crop);
        }
        Get.back();
        if (img != null) {
          callBack.call(img);
        } else {
          CommonHelper.showToast("上传失败".tr);
        }
      });
}