getHomeDirectory function
String?
getHomeDirectory(
{ - bool throwIfNull = false,
})
Implementation
String? getHomeDirectory({bool throwIfNull = false}) {
String? homeDir;
switch (Platform.operatingSystem) {
case 'linux':
case 'macos':
homeDir = Platform.environment['HOME'];
break;
case 'windows':
homeDir = Platform.environment['USERPROFILE'];
break;
case 'android':
homeDir = '/storage/sdcard0';
break;
case 'ios':
case 'fuchsia':
default:
homeDir = null;
}
if (throwIfNull && homeDir == null) {
throw ('\nUnable to determine your home directory: please set environment variable\n\n');
}
return homeDir;
}