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

Can't call openCropper function with iOS platform #15

Closed nguyenxuankiet262 closed 7 months ago

nguyenxuankiet262 commented 7 months ago

I'm using iphone 11 promax, os 17.2.1, xcode 15.1, Flutter SDK 3.3.9

it worked fine when crop images in openPicker function but when i call openCropper function, i got this issue

Attempt to present <CropViewController.CropViewController: 0x1062b1090> on <TLPhotoPicker.TLPhotosPickerViewController: 0x107857c00> (from <TLPhotoPicker.TLPhotosPickerViewController: 0x107857c00>) whose view is not in the window hierarchy.

howljs commented 7 months ago

Please provide me with the logic of the code you are using. I will assist as quickly as possible

howljs commented 7 months ago

@nguyenxuankiet262 This error occurs when you call openCropper while openPicker has not yet closed.

nguyenxuankiet262 commented 7 months ago

@nguyenxuankiet262 This error occurs when you call openCropper while openPicker has not yet closed.

  • Can you tell me what functionality you are looking for?
  • Why not use the cropper directly within openPicker?

Hi! Thank for quick response

I have a function pick and crop multiple images so i can't use openPicker for cropping multiple images. I must use openCropper function to crop selected images picked from openPicker

nguyenxuankiet262 commented 7 months ago

Please provide me with the logic of the code you are using. I will assist as quickly as possible

final medias = await _picker.openPicker( cropping: true, localized: LocalizedImagePicker(), pickerOptions: HLPickerOptions( convertHeicToJPG: true, enablePreview: true, maxDuration: 60, maxSelectedAssets: 5, maxFileSize: 100 * 1024, usedCameraButton: false, mediaType: MediaType.image, convertLivePhotosToJPG: true, ), cropOptions: HLCropOptions( aspectRatioPresets: [CropAspectRatioPreset.original, CropAspectRatioPreset.square], compressQuality: 1, compressFormat: CompressFormat.jpg, croppingStyle: CroppingStyle.normal, ), ); if (medias.length > 1) { List<HLPickerItem> pickMedias = []; for (var image in medias) { try { var pickMedia = await _picker.openCropper( image.path, localized: LocalizedImagePicker(), cropOptions: HLCropOptions( aspectRatioPresets: [CropAspectRatioPreset.original, CropAspectRatioPreset.square], compressQuality: 1, compressFormat: CompressFormat.jpg, croppingStyle: CroppingStyle.normal, ), ); pickMedias.add(pickMedia); } catch (err) { print("err: $err"); } } }

howljs commented 7 months ago

Currently, the library does not support cropping multiple images at once. You will need to use await Future.delayed(const Duration(seconds: 1)); to ensure that openPicker is closed before using openCropper.

Screenshot 2023-12-21 at 20 23 29

howljs commented 7 months ago

I will consider implementing the functionality to crop multiple images right now

howljs commented 7 months ago

@nguyenxuankiet262 The feature to crop multiple images has been supported. You can update to the new version