Search code examples
iosxcodeflutterdartimagepicker

Flutter Image Picker problem on iOS, pop-up with "Select more photos" even if I want to select only one, the image is not added


I am using Image Picker to select an image from the gallery. When I don't have any images uploaded, after I add one image, this pop-up is appearing as shown below. enter image description here

If I press "Select More Photos...", the image or images are not added after selection. How to get rid of this pop-up or what do I need to change in my code to be able to Select More Photos if he wants. I read that Image Picker is unable to handle picking multiple images once, and I don't need that necessarily, so I need to get rid of this pop-up, because even if I select only one image from "Select more photos...", it is not added.

 void _openCameraAndAddPossibleImage(String? cleverClosetOrganizer, String cameraOrGallery, int isMyClosetCheck) async{
    try{
      var pickedFile = await ImagePicker().pickImage(
        source: cameraOrGallery == 'camera' ? ImageSource.camera : ImageSource.gallery,
      );
      if (pickedFile != null) {
        var imageFile = File(pickedFile.path);
        Uint8List imageRaw = await imageFile.readAsBytes();
        String newImage = CleverCloset.base64String(imageRaw);
        if (mounted) {
        setState(() {
          if(isMyClosetCheck==1) {
            CleverCloset cleverClosetToAdd = CleverCloset(closetOrganizer: cleverClosetOrganizer, isMyCloset: isMyClosetCheck, image: newImage);
            addImageOnClosetOrganizer(cleverClosetToAdd);
          }
          else {
            CleverCloset cleverClosetToAdd = CleverCloset(isMyCloset: isMyClosetCheck, image: newImage);
            addImageOnToBuy(cleverClosetToAdd);
          }
        });

        }
      }
    }
   catch (e){
      return ;
   }

  }

enter image description here


Solution

  • Based on this discussion https://github.com/flutter/flutter/issues/65995, I find out that it's a common bug on iOS.

    I solved this issue by adding:

     image_picker:
        git:
          url: https://github.com/cpboyd/plugins.git
          ref: ios-no-permissions
          path: packages/image_picker/image_picker
    

    Using this branch, it will remove the pop-up.