addEnvironmentVariable method

void addEnvironmentVariable(
  1. String key,
  2. String value
)

Adds an environment variable to the current process

Parameters:

  • key: The name of the environment variable
  • value: The value of the environment variable

This method handles platform-specific differences in setting environment variables.

Implementation

void addEnvironmentVariable(String key, String value) {
  if (Platform.isWindows) {
    _addEnvironmentVariableWindows(key, value);
  } else if (Platform.isLinux || Platform.isMacOS) {
    _addEnvironmentVariableUnix(key, value);
  } else {
    throw UnsupportedError(
      'Unsupported platform: ${Platform.operatingSystem}',
    );
  }
}