shareFile function

Future<void> shareFile(
  1. String data
)

Implementation

Future<void> shareFile(String data) async {
  try {
    final parsed = jsonDecode(data);
    // data {"title":"Shared Image","text":"Take a look at this image","url":"<file_url>"}
    final filePath = await download(parsed['url']);
    await SharePlus.instance.share(
      ShareParams(files: [XFile(filePath)],),
    );
  } catch (e) {
    throw Exception('Error fetching file: $e');
  }
}