Конструктор String.fromEnvironment const
const String.fromEnvironment(Возвращает строковое значение объявления среды name.
Объявления среды предоставляются окружающей системой, компилирующей или выполняющей программу Dart. Объявления сопоставляют строковый ключ со строковым значением.
Если name не объявлено в среде, результат вместо этого defaultValue.
Пример получения значения:
const String.fromEnvironment("defaultFloo", defaultValue: "no floo")
Пример проверки, существует ли объявление вообще:
var isDeclared = const String.fromEnvironment("maybeDeclared") != null;
Исходный код
// The .fromEnvironment() constructors are special in that we do not want
// users to call them using "new". We prohibit that by giving them bodies
// that throw, even though const constructors are not allowed to have bodies.
// Disable those static errors.
//ignore: const_constructor_with_body
//ignore: const_factory
external const factory String.fromEnvironment(String name,
{String defaultValue});
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-core/String/String.fromEnvironment.html