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 ?? [const Text("相册选择"), const Text("拍摄照片")],
      cancel: cancel,
      onConfirm: (val) async {
        List<Permission> permissionList = [
          Permission.storage,
          Permission.camera
        ];
        final permissions =
            await PermissionHelper.checkPermission([permissionList[val]]);
        if (!permissions) {
          return CommonHelper.showToast('Please enable related permissions');
        }
        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);
        }
      });
}