I am facing an issue to share image file from flutter app.
I have downloaded and saved the file to directory = await getApplicationDocumentsDirectory(); and the file is from firestore.
Now when I am trying to share the file its sending BIN file, how can I send it as Image ?
Here is the file path /data/user/0/com.salegurusaller.leadsmarketing/app_flutter/Leads/products%2F1665586225384_rrxGbQjZd13dXzNjizM6_image_picker5704112476130713758.jpg?alt=media&token=37171ed7-d05c-439f-a693-39f2c6aac2cd
Here is my codes while I am sharing the file using share_link plugin
Future shareSelected({required List<ProductImage> productsListForShare})async {
if (productsListForShare.isNotEmpty) {
final files = <XFile>[];
for (var i = 0; i < productsListForShare.length; i++) {
print(productsListForShare[i].photo!.path!);
var xfile = XFile(productsListForShare[i].photo!.path!,);
files.add(xfile);
}
await Share.shareXFiles(files);
} else {
Get.snackbar("Share error", "Unable to share, there is some error");
}
}
I have resolved it renaming the file while download. I was saving the file same as the url link now I have modified it with proper extension.
Previously I have saved my file as
/data/user/0/com.salegurusaller.leadsmarketing/app_flutter/Leads/products%2F1665586225384_rrxGbQjZd13dXzNjizM6_image_picker5704112476130713758.jpg?alt=media&token=37171ed7-d05c-439f-a693-39f2c6aac2cdNow I am saving it as
/data/user/0/com.salegurusaller.leadsmarketing/app_flutter/Leads/products%2F1665586225384_rrxGbQjZd13dXzNjizM6_image_picker5704112476130713758.jpgThis resolved my issue