Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share image format not supported #18

Open
lodemo opened this issue Jan 11, 2019 · 5 comments
Open

Share image format not supported #18

lodemo opened this issue Jan 11, 2019 · 5 comments

Comments

@lodemo
Copy link

lodemo commented Jan 11, 2019

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();
@iesmail3
Copy link

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

@lodemo
Copy link
Author

lodemo commented Jan 22, 2019

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 lodemo closed this as completed Jan 22, 2019
@lodemo lodemo reopened this Jan 22, 2019
@OlivlfilipeOliveira
Copy link

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

@lodemo
Copy link
Author

lodemo commented Feb 26, 2019

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.

@OlivlfilipeOliveira
Copy link

OlivlfilipeOliveira commented Feb 26, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants