Flutter image_picker PlatformException(missing_valid_image_uri, Cannot find at least one of the selected images., null, null)
image_picker package gives the following exception when picking single or multiple images on real device. it's working on emulators and simulators.
so the returned path of the picked image is always null, here's a code snippet:
Future pickMultipleImages() async {
final ImagePicker picker = ImagePicker();
final List images = await picker.pickMultiImage(); // exception here
// this condition never reached
if (images.isNotEmpty) {
final availableSlots = maxImagesCount - adImages.length;
if (availableSlots > 0) {
final imagesToAdd = images
.take(availableSlots)
.map((e) => e.path)
.toList();
adImages.addAll(imagesToAdd);
emit(CreateAdChangedImagesState());
}
}
}
also picking a single image fails on real devices, here's the error in logs:
E/flutter (15412): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(missing_valid_image_uri, Cannot find at least one of the selected images., null, null)
E/flutter (15412): #0 ImagePickerApi.pickImages (package:image_picker_android/src/messages.g.dart:463:7)
messages.g.dart:463
E/flutter (15412):
E/flutter (15412): #1 ImagePickerAndroid.getMultiImageWithOptions (package:image_picker_android/image_picker_android.dart:232:32)
image_picker_android.dart:232
E/flutter (15412):
E/flutter (15412): #2 CreateAdCubit.pickMultipleImages (package:bindo_app/feature/create_ad_tab/logic/create_ad_cubit/create_ad_cubit.dart:279:32)
create_ad_cubit.dart:279
E/flutter (15412):
E/flutter (15412):