flutter-share icon indicating copy to clipboard operation
flutter-share copied to clipboard

Share image format not supported

Open lodemo opened this issue 6 years ago • 5 comments

Hi, im trying to share an image through Share.image(...) but for every app the share is opened, a message is shown that the format is not supported.

Im writing the file to the external directory beforehand, in PNG format.

WhatsApp, GMail etc. are all displaying the format is not supported but i cant image they dont support PNG.

Is there something wrong with my share or what could be the reason?

var byteData = await image.toByteData(format: ImageByteFormat.png);
await File(path).writeAsBytes(byteData.buffer.asUint8List());

Share.image(path: 'content://$path',
  mimeType: ShareType.TYPE_IMAGE).share();

lodemo avatar Jan 11 '19 22:01 lodemo

Were you able to resolve this issue? I am having the same issue. I would appreciate if you could share your findings.

iesmail3 avatar Jan 22 '19 18:01 iesmail3

I didnt look into it anymore until now, but after your request i tried again just now and indeed found a solution which seems to work for me.

Instead of the 'content://...' path which i found suggested alot for android, using the path returned from Uri.file().toFilePath() works for me, tested on Android only.

Edit: Maybe i was to hasty, sharing the image to WhatsApp seems to work, GMail however shows an error saying it could not attach the file, testing it with a file explorer shows no error and the saved file exists, but is empty with size zero bytes.

final RenderBox box = context.findRenderObject();
Share.image(path: Uri.file(path).toFilePath(),
    mimeType: ShareType.TYPE_IMAGE).share(
    sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);

lodemo avatar Jan 22 '19 19:01 lodemo

were you able to retrieve the file image and share it?

OlivlfilipeOliveira avatar Jan 28 '19 14:01 OlivlfilipeOliveira

No i couldnt get it to work using the file path.

Im now using esys-flutter-share which supports text and image shares, and is using the image byte data directly instead of a path, which seems to solve the issue.

lodemo avatar Feb 26 '19 23:02 lodemo

Use this https://pub.dartlang.org/packages/share_extend .

Em ter, 26 de fev de 2019 20:10, lodemo [email protected] escreveu:

No i couldnt get it to work using the file path.

Im now using esys-flutter-share https://github.com/esysberlin/esys-flutter-share which supports text and image shares, and is using the image byte data directly instead of a path, which seems to solve the issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/d-silveira/flutter-share/issues/18#issuecomment-467653517, or mute the thread https://github.com/notifications/unsubscribe-auth/ARGrJBF7zfzNqYMaaQLrNYj-Vsvyrv-kks5vRb7rgaJpZM4Z8RJX .

OlivlfilipeOliveira avatar Feb 26 '19 23:02 OlivlfilipeOliveira