shareFile method

void shareFile({
  1. required BuildContext context,
  2. required String path,
})

Implementation

void shareFile({
  required BuildContext context,
  required String path,
}) async {
  var size = MediaQuery.of(context).size;
  await Share.shareXFiles(
    [XFile(path)],
    sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2),
  ).then((ShareResult shareResult) {
    if (shareResult.status == ShareResultStatus.success && context.mounted) {
      ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('File saved successfully')));
    }
  });
}