12

I'm trying to write a feature that allows a user to select an image from their gallery on iOS. I'm able to capture the image from the camera, but when I try to do the same from the image gallery, my app crashes.

I made sure that I'm using the latest version of the plugin (0.6.0), and have tried running the app both in the simulator and on my iOS device. I'm currently using an iPhone 8 simulator running iOS 12.4, and my device is an iPhone 7+, also on iOS 12.4

// opens the camera for use, works as expected
// does not currently store the image anywhere, but I know why

  void _showCamera() async {
    var picture = await ImagePicker.pickImage(
      source: ImageSource.camera
    );
  }
// this code crashes
  void _showImageGallery() async {
    var picture = await ImagePicker.pickImage(
      source: ImageSource.gallery
    );
  }

If I call _showCamera() from my onTap: callback, the camera opens without issue. When I call _showImageGallery() from the exact same onTap: callback, the app crashes. I'd expect it to work the same since they're otherwise identical functions.

3 Answers 3

21

I think you missed adding the NSPhotoLibraryUsageDescription to the info.plist file

Sign up to request clarification or add additional context in comments.

3 Comments

Wow. Yeah, that was it. Thanks for the help. I added the entries for the camera and the microphone but not the photo library.
its helped me.. just paste the code in info.plist <key>NSPhotoLibraryUsageDescription</key> <string>Photo Library Access Warning</string>
In case this helps somebody elser, I had the key, but there was an space before the closing </key>
0

This issue exists on flutter stable channel. Switch to flutter beta channel to resolve this issue. Use this command to switch the flutter channel:

flutter channel beta

Comments

0

You may have to select the Signing Account in Xcode.

Also add NSPhotoLibraryUsageDescription in info.plist.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.