From b51c0d9774e6f43588c0479a008e9b81c2c7a97a Mon Sep 17 00:00:00 2001 From: Julien <120588494+julien4215@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:39:45 +0200 Subject: [PATCH] fix filesaver for web --- .../pages/past_ph_selection_page/ph_list.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/ph/ui/pages/past_ph_selection_page/ph_list.dart b/lib/ph/ui/pages/past_ph_selection_page/ph_list.dart index 8b88a1ab3..e9dbe1c7d 100644 --- a/lib/ph/ui/pages/past_ph_selection_page/ph_list.dart +++ b/lib/ph/ui/pages/past_ph_selection_page/ph_list.dart @@ -56,12 +56,19 @@ class PhList extends HookConsumerWidget { dataBuilder: (context, pdf) => PhCard( ph: ph, onDownload: () async { - final path = await FileSaver.instance.saveAs( - name: ph.name, - bytes: pdf.last, - ext: "pdf", - mimeType: MimeType.pdf, - ); // Not yet possible to save directly the file to Download folder + final path = kIsWeb + ? await FileSaver.instance.saveFile( + name: ph.name, + bytes: pdf.last, + ext: "pdf", + mimeType: MimeType.pdf, + ) + : await FileSaver.instance.saveAs( + name: ph.name, + bytes: pdf.last, + ext: "pdf", + mimeType: MimeType.pdf, + ); if (path != null) { displayPhToastWithContext( TypeMsg.msg,