Search code examples
flutterflutter-ios

Flutter ios app lost connection on calling ImagePicker.getImage() with no error


This is the gif showing app crashed https://media.giphy.com/media/Qm9PALMAtAw2W4AUzf/giphy.gif

onPressed: () => _pickImage(),
Future _pickImage() async {
    image = await _picker.getImage(source: ImageSource.gallery);
}

There's no error message or anything, just lost connection to device

This lost connection behavior also happend when calling Navigator.pop() to close dialog


Solution

  • Add below line in Info.plist

    <key>NSCameraUsageDescription</key>
    <string>Can i get permission to pick image?</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Can i get permission to pick image?</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Can i get permission to pick image?</string>