fluttercommunity / plus_plugins

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

[Request]: Improve documentation for filename used in shareXFiles #3032

Closed frieder-audriga closed 2 months ago

frieder-audriga commented 3 months ago

Plugin

share_plus

Use case

When sharing a file that is created from data, like so

      var data = utf8.encode('Hello World');
      var fileName = 'myFile.txt';
      var mimeType = 'text/plain';
      var xFile = XFile.fromData(data, name: fileName, mimeType: mimeType);
      Share.shareXFiles([xFile]);

expected behavior would be that a file called "myFile.txt" would be shared. Instead "{randomUUID}.txt" gets shared.

This is caused by cross_file ignoring the name parameter, when creating an xFile via the fromData constructor see cross_file/lib/src/types/io.dart:43

This then causes share_plus to assign a name based on a random UUIDv6 and the mimetype.

Proposal

Ideally a convenient way (for example an optional parameter) would be introduced that allows us to set/ override the filename of a given file to share.

But if that is not wanted for some reason at least please add to the documentation that

frieder-audriga commented 3 months ago

Note: I am not the only one that is confused by this, see https://github.com/fluttercommunity/plus_plugins/issues/1548#issuecomment-2072047472 and following comments

vbuberen commented 3 months ago

Thanks for reporting. PR is more than welcome with your suggestion.