const String.fromEnvironment(String name, { String defaultValue })

Returns the string value of the environment declaration name.

Environment declarations are provided by the surrounding system compiling or running the Dart program. Declarations map a string key to a string value.

If name is not declared in the environment, the result is instead defaultValue.

Example of getting a value:

const String.fromEnvironment("defaultFloo", defaultValue: "no floo")

Example of checking whether a declaration is there at all:

var isDeclared = const String.fromEnvironment("maybeDeclared") != null;

Source

external const factory String.fromEnvironment(String name,
                                              {String defaultValue});