diff --git a/lib/utils/system_util.dart b/lib/utils/system_util.dart index 92312a2..eb3cc78 100644 --- a/lib/utils/system_util.dart +++ b/lib/utils/system_util.dart @@ -6,9 +6,9 @@ import 'dart:typed_data'; import 'package:yaml/yaml.dart'; import 'package:path/path.dart' as path; -late String Function() getUserPath; -late String Function() getProjectName; -late String Function() getDataPath; +late Future Function() getUserPath; +late Future Function() getProjectName; +late Future Function() getDataPath; void initialize() { getUserPath = getUserPath_; @@ -115,7 +115,7 @@ Future readFileByte(String filePath) async { return c.future; } -String getUserPath_() { +Future getUserPath_() async { String home = ''; Map envVars = Platform.environment; if (Platform.isMacOS) { @@ -125,11 +125,13 @@ String getUserPath_() { } else if (Platform.isWindows) { home = envVars['UserProfile']!; } - return home; + var c = Completer(); + c.complete(home); + return c.future; } -String getDataPath_() { - String path = getUserPath(); +Future getDataPath_() async { + String path = await getUserPath(); if (Platform.isMacOS) { path = '$path/Library/Application Support/${getProjectName()}'; } else if (Platform.isLinux) { @@ -137,15 +139,19 @@ String getDataPath_() { } else if (Platform.isWindows) { path = '$path/AppData/Local/${getProjectName()}'; } - return path; + var c = Completer(); + c.complete(path); + return c.future; } -String getProjectName_() { +Future getProjectName_() async { var name = path.dirname(Platform.script.toFilePath(windows: Platform.isWindows)); print(name); if (path.basename(name) == 'bin') { name = path.dirname(name); } - return path.basename(name); + var c = Completer(); + c.complete(path.basename(name)); + return c.future; }