[Request]: Improve documentation for filename used in shareXFiles
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
- A random filename is assigned to files that have no filename set
- A note that
XFile.fromDataignores the the filename- I am aware that cross_file is a separate project, but at least when navigating the API docs it is not possible to find this information.
- For example https://pub.dev/documentation/share_plus/latest/share_plus/XFile/XFile.fromData.html lists no such note.
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
Thanks for reporting. PR is more than welcome with your suggestion.