plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Request]: Sharing on windows shares only text

Open TonyHoyleRps opened this issue 2 years ago • 8 comments

Plugin

share_plus

Use case

On windows the sharing dialog always shows a link to the file rather than a preview, and always shares the path to the file, which may be temporary and linked to a single machine.

image

image

This makes the sharing action pretty pointless IMO. Now it may be a limitation of Windows (hence labelling as enhancement) but it would be really nice to have useful file sharing from flutter on windows even if someone has to code a new dialog..

Proposal

Ideally, something like this.. but just a text replacement would suffice, as long as it's possible to share a file.

image

TonyHoyleRps avatar Feb 06 '23 11:02 TonyHoyleRps

Show your code.

alexmercerind avatar Feb 08 '23 08:02 alexmercerind

It's literally a single line,.. this works correctly on ios and android.

Share.shareXFiles([XFile(image.filename)],
    subject: "Conservatory",
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

TonyHoyleRps avatar Feb 08 '23 11:02 TonyHoyleRps

Hi! Can you use Share.shareFiles instead?

I made the Windows implementation in C++/WRL for package:share_plus, where you can see that it's working correctly. Share.shareXFiles is a newer API which still internally calls Share.shareFiles, it might be that it needs some changes specific to Windows.

alexmercerind avatar Feb 08 '23 12:02 alexmercerind

As expected, that makes no difference.

Share.shareFiles([image.filename],
    subject: "Conservatory",
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

I have also tried:

Share.shareFiles([image.filename], mimeTypes: ["image/png"],
    subject: "Conservatory",
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

and

Share.shareFiles([image.filename], mimeTypes: ["image/png"],
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

The last one causes the share dialog to fail with an error 'Try that again' (presumably subject is mandatory).

TonyHoyleRps avatar Feb 09 '23 11:02 TonyHoyleRps

As expected, that makes no difference.

Share.shareFiles([image.filename],
    subject: "Conservatory",
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

I have also tried:

Share.shareFiles([image.filename], mimeTypes: ["image/png"],
    subject: "Conservatory",
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

and

Share.shareFiles([image.filename], mimeTypes: ["image/png"],
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

The last one causes the share dialog to fail with an error 'Try that again' (presumably subject is mandatory).

The best guess I can make is to try sharing some another file path (check for some file that exists on your system). Your file path seems to be shortened by Windows (the ~1 symbol).

alexmercerind avatar Feb 14 '23 09:02 alexmercerind

I just tried with a fixed path:

Share.shareXFiles([XFile(r"D:\Test.PNG")],
    subject: "Conservatory",
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2));

And it did exactly the same thing.

TonyHoyleRps avatar Feb 17 '23 12:02 TonyHoyleRps

+1

selvam920 avatar Oct 13 '23 15:10 selvam920

Just in case someone else comes across this issue, the path should be formatted as on windows.

In my case it was enough to do:

path.replaceAll("/", "\\");

and it was working fine

adywizard avatar May 12 '24 12:05 adywizard