Image not be picked in iOS simulator

1,064

You have to add the below permission in Info.plist file in XCode.

Camera :

Key       :  Privacy - Camera Usage Description   
Value     :  $(PRODUCT_NAME) camera use

Photo :

Key       :  Privacy - Photo Library Usage Description    
Value     :  $(PRODUCT_NAME) photo use
Share:
1,064
Admin
Author by

Admin

Updated on December 22, 2022

Comments

  • Admin
    Admin over 1 year

    I am using the below code to get pick image in flutter application, when the code is run on Android it works fine, but when the same code is run on iOS it crashes the app while tapping the button to pick the image. How should I resolve it?

    ERROR I GET

    Lost connection to device.

    final ImagePicker _picker = ImagePicker();
      Future getImage() async {
        print("get image");
    
        PickedFile image = await _picker.getImage(source: ImageSource.gallery);
    
        if (image != null) {
          setState(() {
            final File file = File(image.path);
            avatarImageFile = file;
            isLoading = true;
    
          });
        }
      }
    

    info.plist propertiesenter image description here

  • Admin
    Admin almost 4 years
    I tried it , but it is till giving the same error, added the info.plist in the question above
  • Nikunj Kumbhani
    Nikunj Kumbhani almost 4 years
    @JohnnyWarner Please share what's the error you got?
  • Nikunj Kumbhani
    Nikunj Kumbhani almost 4 years
    @JohnnyWarner Please try to run in the real device after clean the project
  • Admin
    Admin almost 4 years
    Resolved it in simulator only by rebuilding the project
  • Abhishek Ghaskata
    Abhishek Ghaskata over 3 years
    Which simulator version are you using? I am getting the same issue after doing this answer. My simulator version is 14.2. @NikunjKumbhani