Reputation: 121
I have implemented the share button using flutter-share plugin to share an image. I used the following code to share the desired image. However, It doesn't work. It shares the text but not the image. Different apps gives different reasons. Reasons includes, Messages: Unable to load the file, Bluetooth: Unknow file format. Gmail: Cannot attach an empty file. BTW, the app already has the read and write permission and I can load the image using Image widget, but it seems that the plugin cannot load the image. Any one knows how to solve this problem or what might be the issue?
Future<String> get _localPath async {
final dir = await getExternalStorageDirectory();
return dir.path;
}
...
filePath = await _localPath;
...
await Share.image(
path: '$filePath/s.jpg',
title: "share it!",
text: "share flutter",
mimeType: ShareType.TYPE_IMAGE)
.share(sharePositionOrigin: cardRect);
Upvotes: 1
Views: 4549
Reputation: 121
After replacing the path address by 'file://$filePath/s.jpg'
the problem got resolved.:
await Share.image(
path: 'file://$filePath/s.jpg',
title: "share it!",
text: "share flutter",
mimeType: ShareType.TYPE_IMAGE)
.share(sharePositionOrigin: cardRect);
Upvotes: 1