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.
I think you missed adding the NSPhotoLibraryUsageDescription
to the info.plist file
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With