add user path
This commit is contained in:
parent
85f2b690b3
commit
6e33dbe656
2 changed files with 16 additions and 0 deletions
|
|
@ -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<String> get userPath async {
|
||||
String path = '';
|
||||
var c = Completer<String>();
|
||||
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 = '/';
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue