Closed whedamd closed 1 week ago
Same problem here
Have the same problem.
my version
file_picker:
dependency: "direct main"
description:
name: file_picker
url: "https://pub.dartlang.org"
source: hosted
version: "4.5.1"
Execution environment
iPhone Simulator: iPhone11
iOS: 15.2
Hi, how are you picking the files?
I am having the same problem. It only happens with one photo and the others work fine. I am using iOS simulator.
Version 4.5.1
.
I am using this method:
await FilePicker.platform.pickFiles(type: FileType.image);
Message:
Temporary file could not be created
Details:
Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x600002ed33f0 {Error Domain=NSCocoaErrorDomain Code=4101 "Błąd komunikacji z aplikacją pomocniczą." UserInfo={NSUnderlyingError=0x600002e7cd80 {Error Domain=PHAssetExportRequestErrorDomain Code=0 "Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.)" UserInfo={NSLocalizedDescription=Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.), NSUnderlyingError=0x600002e7fd20 {Error Domain=PAMediaConversionServiceErrorDomain Code=2 "Nie można ukończyć tej operacji. (Błąd PAMediaConversionServiceErrorDomain 2.)" UserInfo=0x60000205b500 (not displayed)}}}}}}
Error from logs:
flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x600002ed33f0 {Error Domain=NSCocoaErrorDomain Code=4101 "Błąd komunikacji z aplikacją pomocniczą." UserInfo={NSUnderlyingError=0x600002e7cd80 {Error Domain=PHAssetExportRequestErrorDomain Code=0 "Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.)" UserInfo={NSLocalizedDescription=Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.), NSUnderlyingError=0x600002e7fd20 {Error Domain=PAMediaConversionServiceErrorDomain Code=2 "Nie można ukończyć tej operacji. (Błąd PAMediaConversionServiceErrorDomain 2.)" UserInfo=0x60000205b500 (not displayed)}}}}}}, null)
For me this only happens in the iOS simulator, on a real iPhone it works fine. I only tried this on a mac M1...
You are probably trying with the pink flowers photo on the simulator — that's a known iOS simulator issue since iOS 14. You should "ignore it". 😄
Same issue happening with me on a real device.
I'm also experiencing this issue. I've been getting this issues on the Xcode simulator running Xcode 13.3.1, iOS 15.4.1, and package version 4.5.1. I have yet to test on a physical device yet.
Before this issue only occurred on the pink flowers picture in the simulator but now its happening with all the pictures. The error message I am getting is:
flutter: unhandled element metadata; Picture key: AssetBundlePictureKey(bundle: PlatformAssetBundle#dd967(), name: "assets/svg/manage-memories-blankstate.svg", colorFilter: null)
flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item}, null)
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item}, null)
And the code I am using to call the file picker is:
final FilePickerResult? pickedFiles = await FilePicker.platform.pickFiles(
type: FileType.media,
allowMultiple: true,
onFileLoading: (FilePickerStatus status) {
print(status);
},
);
EDIT: I can't reproduce it on a physical device so it looks like a simulator issue (for me at least)
Inside info.plist
Package: image_picker: ^0.8.4+11 Implementation: Uint8List? pickPhoto(ImageSource source) async { XFile file = await _picker.pickImage(source: source); if (file != null) { return Uint8List photo = await file.readAsBytes(); } return null; }
+1 for any picture on simulator
Update: it seems that if you exclude arm64 from Excluded Architectures from Target -> Runner, you'll get the error. If you remove it, it's working again. In my case I needed to exclude the arm64, because of another Pod that gets me another error (I've tried the solution to only exclude arm64 from the pods, but in my case it's only working if I exclude it from Runner), so I don't know what the best workaround or fix for this would be.
@miguelpruivo I tried with code block
/// Uploads the file to the device.
/// This function will return the list of files.
static Future<Set<PlatformFile>> uploadFile(
[FileType? fileType,
bool? allowMultipleFiles,
List<String>? extensions]) async =>
(await FilePicker.platform.pickFiles(
type: fileType ?? FileType.any,
allowMultiple: allowMultipleFiles ?? false,
allowedExtensions: extensions))
?.files
.toSet() ??
<PlatformFile>{};
Called it here
IconButton(
icon: const Icon(
TablerIcons.photo,
color: Colors.black,
),
onPressed: () async {
try {
// await controller!.stopCamera();
Set<PlatformFile> _file =
await AppService.uploadFile(FileType.image);
if (_file.isNotEmpty) {
bool _gotData = await AppService.getQRData(
_scaffoldKey.currentContext!,
_file.first.path,
);
if (_gotData) {
await Navigator.pushReplacementNamed(
context, PageRoutes.activatingAtSign);
}
} else {
await controller!.startCamera(onScan);
await showToast(
'No image picked', _scaffoldKey.currentContext!, true);
}
} on Exception catch (e) {
await controller!.stopCamera();
qrLog.severe(e);
await showToast('Failed to pick image',
_scaffoldKey.currentContext!, true);
}
},
),
And the below is result.
Why this issue is closed?
You are probably trying with the pink flowers photo on the simulator — that's a known iOS simulator issue since iOS 14. You should "ignore it". 😄
I'm also experiencing this issue (Mac M1, iPhone Simulator with iOS 15.5). It looks like it was prematurely closed if this comment was the reason for closing this.
Looking at this similar package image_picker their readme states:
As a result of implementing PHPicker it becomes impossible to pick HEIC images on the iOS simulator in iOS 14+. This is a known issue. Please test this on a real device, or test with non-HEIC images until Apple solves this issue.
If file_picker's case is the same it would be useful to know it!
Will there be a resolution for this ?
May be this should be fixed from apple 😅
I am not even picking that flower image but still getting that error on the Mac M1 chip. Any fixes ?
This is still not working
Seems to be random. On my MacBox pro, it is fined, on M1 (used to work but no longer working).
I am not even picking that flower image but still getting that error on the Mac M1 chip. Any fixes ?
can I help you?
@NabeelAbid1812 sure
same here still got the same problem... 19/12/2022
mac mini m1
I also recently had the same issue on iphonesimulator with media picking. However, I managed to make it work by changing Document Storage to "On My iPhone" and restarting app. Also try select not first media file, but any other.
Hello @miguelpruivo! I managed to reproduce this error on a real device. To do this, I tried to select a live photo from the gallery. At the same time, the photo was very old (taken on another iphone) and stored in iCloud. It seems the combination of iCloud and live-photo may be the key to the solution
also have the same problem. Any solution? flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x28309be40 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x28309a670 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 16965 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 16965 on anonymousListener or serviceListener}}}}}, null) [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x28309be40 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x28309a670 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 16965 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 16965 on anonymousListener or serviceListener}}}}}, null)
Facing the same issue as well. need t fix this ASAP
I am facing this issue on real ios device.
Also facing the same issue on real iphone device
We are also facing this issue in semi large scale on production devices
I am facing the same issue when I used the following settings on my physical iPhone: Settings -> Camera -> Formats -> Most Compatible.
This issue is stale because it has been open for 7 days with no activity.
Faced the issue with live photos taken with iPhone camera app. If I turn off the live feature, I'm able to upload the image.
This issue is stale because it has been open for 7 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item}, null)
Platform: iOS