getEnv method
Extension on InternalSystemContext
that provides access to system-level
and environment-related properties similar to Java's System.getProperties()
and System.getenv()
.
This includes metadata about the Dart runtime, host operating system, environment variables, and more.
Example
final properties = context.getProperties();
print(properties['os.name']); // e.g., 'macos'
final dartVersion = context.getProperty('dart.version');
print(dartVersion); // e.g., '3.3.0'
final env = context.getEnv();
print(env['PATH']);
final home = context.getEnvVar('HOME');
print(home);
Useful in cross-platform utilities, diagnostics, and configuration loading.
Returns a map of the environment variables accessible to the current Dart process.
Equivalent to Java’s System.getenv()
.
Example
final env = context.getEnv();
print(env['PATH']);
Implementation
Map<String, String> getEnv() => io.Platform.environment;