getHomeDir function

String getHomeDir()

Retrieves the user's home directory path.

Uses environment variables to determine the home directory based on the operating system.

Implementation

String getHomeDir() {
  String home = "";
  Map<String, String> envVars = Platform.environment;
  if (Platform.isMacOS || Platform.isLinux) {
    home = envVars['HOME'] ?? home;
  } else if (Platform.isWindows) {
    home = envVars['UserProfile'] ?? home;
  }
  return home;
}