diff --git a/lib/utils/path.dart b/lib/utils/path.dart index 356b87c..8e0dd38 100644 --- a/lib/utils/path.dart +++ b/lib/utils/path.dart @@ -1,10 +1,25 @@ import 'dart:io'; import 'dart:async'; import 'package:path/path.dart' as path; +import 'package:path_provider/path_provider.dart'; enum FileType { none, file, directory, link } class Path { + static Future get userPath async { + String path = ''; + var c = Completer(); + if(Platform.isWindows) { + path = Platform.environment['USERPROFILE'] as String; + } else if(Platform.isMacOS || Platform.isLinux) { + path = Platform.environment['HOME'] as String; + } else if(Platform.isAndroid || Platform.isIOS) { + path = (await getApplicationDocumentsDirectory()).path; + } + c.complete(path); + return c.future; + } + static String? getParent(String path) { path = getNormal(path); var separator = '/'; diff --git a/pubspec.yaml b/pubspec.yaml index f141ee0..ade540d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,6 +9,7 @@ environment: # Add regular dependencies here. dependencies: path: ^1.8.2 + path_provider: ^2.0.14 args: ^2.3.2 json_annotation: ^4.8.1 archive: ^3.3.5