summaryrefslogtreecommitdiff
path: root/lib/services/backup_helper_service.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/services/backup_helper_service.dart')
-rw-r--r--lib/services/backup_helper_service.dart30
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);
+ }
+ }
+}