fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.61k stars 972 forks source link

[Request]: Sharing on windows shares only text #1517

Open TonyHoyleRps opened 1 year ago

TonyHoyleRps commented 1 year ago

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

alexmercerind commented 1 year ago

Show your code.

TonyHoyleRps commented 1 year ago

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));
alexmercerind commented 1 year ago

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.

TonyHoyleRps commented 1 year ago

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).

alexmercerind commented 1 year ago

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).

TonyHoyleRps commented 1 year ago

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.

selvam920 commented 1 year ago

+1

adywizard commented 5 months ago

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