-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I'm using the image_picker dependency for my application and I'm using it both for image and video selection.
However for video selection I used to execute _picker.pickMultiImage(..) which seems to be working fine on Android and on latest iOS devices.
However users are now reporting that on iOS12 this triggers the camera instead of the image pickers.
The release notes state:
0.8.1
Add a new method getMultiImage to allow picking multiple images on iOS 14 or higher and Android 4.3 or higher. Returns only 1 image for lower versions of iOS and Android.
So I would suspect if I run this on an iOS12 device to just launch the single image picker instead, however I suspect that in this fallback scenario that is implemented the image source is defaulted to camera instead of gallery.
To make it work however I needed to write myself something like this:
if (Platform.isIOS) {
var operatingSystemVersion = Platform.operatingSystemVersion;
logger.d("Detected iOS device. Version: $operatingSystemVersion");
var iosVersion = double.parse(operatingSystemVersion.split(" ")[1]);
if (iosVersion < 14.0) {
logger.d("iOS device does not support multi image selection, falling back to single image selection");
var imageFiles = _picker.pickImage(
source: ImageSource.gallery,
imageQuality: 50,
maxWidth: 1024,
maxHeight: 1024,
);
imageFiles.then((file) {
if (file != null) {
AnalyticsManager.event(AnalyticsEvent.ON_EDIT_MESSAGE_ADD_ATTACHMENT_IMAGE_SELECTED, parameters: {"count": 1});
Navigator.pop(context);
_openAttachmentsPane();
logger.d("Image file selection done");
_processImageAttachmentfile(MXFile(file));
} else {
AnalyticsManager.event(AnalyticsEvent.ON_EDIT_MESSAGE_ADD_ATTACHMENT_IMAGE_SELECTION_CANCELLED);
logger.d("No image selected...");
}
});
return;
}
}So this works for me, however I think it should be fixed in the library to fallback to the gallery source instead of the camera source.