I am using the share_plus - package for sharing a PDF. It is working, but I want to pass the original name of the PDF-file. Currently my PDFs always get a random name (e.g. "9caef563-bdbe-4cb2-85d2-e582870bbdd3.pdf"), even though I am passing the name:
final response = await Dio().get(
event.url,
options: Options(
headers: headers,
responseType: ResponseType.bytes,
),
);
final result = await Share.shareXFiles(
[
XFile.fromData(
response.data,
mimeType: 'application/pdf',
name: event.filename,
),
],
);
What am I missing here? Why is it not passing the correct name?
This seems to be an open issue on github.
The current workaround is setting a file path for the file you're creating.You could try passing the 'path' property to XFile.fromData or, creating a new file and then passing it to your share.