From 629db8d6250bfbab82508e3ab1f083c0e38f605b Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Fri, 9 Jun 2023 21:38:29 +0200 Subject: debug logging --- lib/services/backup_helper_service.dart | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/services/backup_helper_service.dart (limited to 'lib/services/backup_helper_service.dart') diff --git a/lib/services/backup_helper_service.dart b/lib/services/backup_helper_service.dart new file mode 100644 index 0000000..7a4b7f0 --- /dev/null +++ b/lib/services/backup_helper_service.dart @@ -0,0 +1,30 @@ +import 'dart:io'; + +import 'package:path_provider/path_provider.dart'; + +class BackupHelperService { + Future getDownloadPath() async { + Directory? directory; + try { + if (Platform.isIOS) { + directory = await getApplicationDocumentsDirectory(); + } else { + directory = Directory('/storage/emulated/0/Download/'); + if (!await directory.exists()) + directory = await getExternalStorageDirectory(); + } + } catch (err, stack) { + print("Cannot get download folder path"); + } + return directory?.path; + } + + Future writeStringToFile(String content, String filename) async { + String? fullpath = await getDownloadPath(); + if (fullpath != null) { + fullpath += filename; + File file = File(fullpath); + file.writeAsString(content); + } + } +} -- cgit v1.2.3-70-g09d2