resolveUserHome static method
Resolves the current user's home directory on all OSes supported by Dart.
Implementation
static String? resolveUserHome() {
final env = Platform.environment;
if (Platform.isWindows) {
final userProfile = env['USERPROFILE'];
if (userProfile != null && userProfile.isNotEmpty) return userProfile;
final homeDrive = env['HOMEDRIVE'];
final homePath = env['HOMEPATH'];
if (homeDrive != null &&
homeDrive.isNotEmpty &&
homePath != null &&
homePath.isNotEmpty) {
return '$homeDrive$homePath';
}
return null;
}
final home = env['HOME'];
if (home != null && home.isNotEmpty) return home;
return null;
}