flutter_photo
flutter_photo copied to clipboard
[IOS] Warning: *IMG* couldn’t be copied to “.image” because an item with the same name already exists.
Code
I'm using the following method to the the path from an AssetEntity:
Future<String> getPath() async {
AssetEntity a = new AssetEntity(id: resourceID);
if (Platform.isIOS)
return (await a.file).path;
else
return (await a.originFile).path;
}
and then using the path to load the full screen picture using the plugin photo_view by @renancaraujo :
return FutureBuilder(
future: getPath(assetId),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
print("Full screen path: ${snapshot.data}");
return PhotoView(
initialScale:
PhotoViewComputedScale.contained * 1,
maxScale: PhotoViewComputedScale.contained * 2,
minScale: PhotoViewComputedScale.contained * 1,
basePosition: Alignment.center,
imageProvider:
getAnyImageProvider(snapshot.data as String));
} else {
return LoadingWidget(AppLocalizations.of(context)
.translate('loading'));
}
}),
To be clear this is the method I use to get the ImageProvider:
ImageProvider getAnyImageProvider(String path) {
assert(path.trim().isNotEmpty);
//if (URL.contains("http")) return CachedNetworkImageProvider(URL);
if (path.contains("assets/")) return AssetImage(path);
return FileImage(File(path));
}
Error
I'm randomly getting this error/warning from IOS and then doesn't allow me to display the picture in full screen:
2020-06-20 10:58:01.860253+0200 Runner[774:233320] error = Error Domain=NSCocoaErrorDomain Code=516 "“IMG_3103.JPG” couldn’t be copied to “.image” because an item with the same name already exists." UserInfo={NSSourceFilePathErrorKey=/var/mobile/Media/DCIM/103APPLE/IMG_3103.JPG, NSUserStringVariant=(Copy),
Do you have an idea of the source of this message? Maybe this can be useful.