From d1a18d0cec2018faf7977d497e8e8be281967594 Mon Sep 17 00:00:00 2001 From: Abinesh Date: Mon, 22 May 2023 14:46:57 +0530 Subject: [PATCH 1/3] KB added --- lib/helper/save_file_web.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/helper/save_file_web.dart diff --git a/lib/helper/save_file_web.dart b/lib/helper/save_file_web.dart new file mode 100644 index 0000000..59f773f --- /dev/null +++ b/lib/helper/save_file_web.dart @@ -0,0 +1,12 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:html'; + +///To save the excel sheet in the web platform. +Future saveAndLaunchFile(List bytes, String fileName) async { + AnchorElement( + href: + 'data:application/octet-stream;charset=utf-16le;base64,${base64.encode(bytes)}') + ..setAttribute('download', fileName) + ..click(); +} From c8afe4a9e0d6dad4bdde0db50cd81a9378c7ce85 Mon Sep 17 00:00:00 2001 From: Abinesh Date: Tue, 23 May 2023 09:15:23 +0530 Subject: [PATCH 2/3] KB file modified --- lib/helper/save_file_mobile_desktop.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/helper/save_file_mobile_desktop.dart b/lib/helper/save_file_mobile_desktop.dart index d862929..f0e6c3b 100644 --- a/lib/helper/save_file_mobile_desktop.dart +++ b/lib/helper/save_file_mobile_desktop.dart @@ -14,9 +14,17 @@ Future saveAndLaunchFile(List bytes, String fileName) async { Platform.isIOS || Platform.isLinux || Platform.isWindows) { - final Directory directory = - await path_provider.getApplicationSupportDirectory(); - path = directory.path; + if (Platform.isAndroid) { + final Directory? directory = + await path_provider.getExternalStorageDirectory(); + if (Platform.isAndroid && directory != null) { + path = directory.path; + } + } else { + final Directory directory = + await path_provider.getApplicationSupportDirectory(); + path = directory.path; + } } else { path = await path_provider_interface.PathProviderPlatform.instance .getApplicationSupportPath(); From 1ea3ea6884f070ff7fcd57c799942dc4c0d1b78d Mon Sep 17 00:00:00 2001 From: Abinesh Date: Tue, 23 May 2023 10:46:53 +0530 Subject: [PATCH 3/3] KB file modified --- lib/helper/save_file_mobile_desktop.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helper/save_file_mobile_desktop.dart b/lib/helper/save_file_mobile_desktop.dart index f0e6c3b..c88d321 100644 --- a/lib/helper/save_file_mobile_desktop.dart +++ b/lib/helper/save_file_mobile_desktop.dart @@ -17,7 +17,7 @@ Future saveAndLaunchFile(List bytes, String fileName) async { if (Platform.isAndroid) { final Directory? directory = await path_provider.getExternalStorageDirectory(); - if (Platform.isAndroid && directory != null) { + if (directory != null) { path = directory.path; } } else {