howljs / hl_image_picker

Simplify media selection, cropping, and camera functionality in your Flutter app. Choose images/videos from the library, crop images, and capture new photos/videos with ease.
https://pub.dev/packages/hl_image_picker
20 stars 12 forks source link

Call up the camera, go to crop, then cancel, no callbacks #32

Open levicn opened 1 month ago

levicn commented 1 month ago
    try {
        final HLPickerItem item = await _hlPicker.openCamera(
          cameraOptions: const HLCameraOptions(
            cameraType: CameraType.image,
          ),
          cropping: true,
          cropOptions: const HLCropOptions(
            aspectRatioPresets: [CropAspectRatioPreset.original, CropAspectRatioPreset.square],
            compressFormat: CompressFormat.jpg,
            compressQuality: .8,
          ),
          localized: LocalizedImageCropper(
              cropDoneText: R.string.selectImageDone,
              cropCancelText: R.string.selectImageCancel,
              cropTitleText: R.string.cropImage
          ),
        );
        _pickCompleted([item]);
      } catch(e) {
        if (e is PlatformException) {
          if (e.code == 'CANCELED') {

          }
        }
        formatPrint(e);
      }

If canceled directly after cropping, the part after await will not be executed

howljs commented 1 month ago

I missed the cancel case. Currently, I don’t have the time. I will try to find time to update it soon. If you can fix it right away, you can create a pull request, and I will merge and publish the new version