diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-06-09 21:38:29 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-06-09 21:38:29 +0200 |
| commit | 629db8d6250bfbab82508e3ab1f083c0e38f605b (patch) | |
| tree | 3645b1c2c64d70cbf44167e2456300ea946a0bc9 /lib/services/backup_helper_service.dart | |
| parent | 97e0c8cef73064d121dcb38ab904e8d5d8ba5cdd (diff) | |
debug logging
Diffstat (limited to 'lib/services/backup_helper_service.dart')
| -rw-r--r-- | lib/services/backup_helper_service.dart | 30 |
1 files changed, 30 insertions, 0 deletions
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<String?> 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<void> writeStringToFile(String content, String filename) async { + String? fullpath = await getDownloadPath(); + if (fullpath != null) { + fullpath += filename; + File file = File(fullpath); + file.writeAsString(content); + } + } +} |
