EnvironmentService class

IO implementation of the environment service.

This implementation is used on all platforms except web (Dart VM, Flutter native, and Flutter desktop).

Environment variable lookup priority:

  1. String.fromEnvironment (--dart-define values)
  2. io.Platform.environment (system environment variables)

The implementation uses String.fromEnvironment with empty string as the default value. If the result is empty, it falls back to checking io.Platform.environment. This allows --dart-define values to take precedence over system environment variables, as per OpenTelemetry specification recommendations.

Implemented types

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

getValue(String key) → String?
Gets the value of an environment variable.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → EnvironmentService
The singleton instance of the EnvironmentService.
no setter
testOverrides ↔ Map<String, String>?
Test-only replacement for the lookup sources. When non-null, values come exclusively from this map (a missing key reads as unset) and still flow through the semicolon-to-comma conversion, so tests get deterministic, in-process control of the environment without spawning subprocesses.
getter/setter pair