EnvValues class
A read-only set of configuration values with typed getters.
PlayxEnv keeps the loaded values in one (see PlayxEnv.values). It can
also wrap any other Map<String, String>, such as remote config:
final config = EnvValues({'RETRIES': '3'});
config.getInt('RETRIES'); // 3
Every type has a maybeGet* getter returning null when the key is
missing or the value can't be converted, and a get* getter returning a
fallback instead.
- Annotations
Constructors
Properties
Methods
-
containsKey(
String key) → bool -
Whether
keyhas a value. -
getBool(
String key, {bool fallback = false}) → bool -
Returns the value of
keyas abool, orfallback. -
getDouble(
String key, {double fallback = -1}) → double -
Returns the value of
keyas adouble, orfallback. -
getDuration(
String key, {required Duration fallback}) → Duration -
Returns the value of
keyas a Duration, orfallback. -
getEnum<
T extends Enum> (String key, List< T> values, {required T fallback}) → T -
Returns the enum value of
valuesmatching the value ofkey, orfallback. -
getInt(
String key, {int fallback = -1}) → int -
Returns the value of
keyas anint, orfallback. -
getList<
T> (String key, {List< T> fallback = const [], T fromJson(dynamic json)?, String separator = ','}) → List<T> -
Returns the value of
keyas a list, orfallback. -
getMap(
String key, {Map< String, dynamic> fallback = const {}}) → Map<String, dynamic> -
Returns the value of
keyparsed as a JSON object, orfallback. -
getNum(
String key, {num fallback = -1}) → num -
Returns the value of
keyas anum, orfallback. -
getObject<
T> (String key, {required T fromJson(dynamic json), required T fallback}) → T -
Returns the value of
keyconverted withfromJson, orfallback. -
getString(
String key, {String fallback = ''}) → String -
Returns the value of
key, orfallbackif it isn't set. -
getUri(
String key, {required Uri fallback}) → Uri -
Returns the value of
keyas a Uri, orfallback. -
isSecure(
String key) → bool -
Whether
keyholds a secure value (seePlayxEnvSettings.secureEnv). -
maybeGetBool(
String key) → bool? -
Returns the value of
keyas abool:true/1orfalse/0(case-insensitive).nullif it isn't set or is anything else. -
maybeGetDouble(
String key) → double? -
Returns the value of
keyas adouble, ornullif it isn't set or isn't a number. -
maybeGetDuration(
String key) → Duration? -
Returns the value of
keyas a Duration, ornullif it isn't set or can't be parsed. -
maybeGetEnum<
T extends Enum> (String key, List< T> values) → T? -
Returns the enum value of
valueswhose name matches the value ofkey(case-insensitive), ornull. -
maybeGetInt(
String key) → int? -
Returns the value of
keyas anint, ornullif it isn't set or isn't a number. Decimals are truncated. -
maybeGetList<
T> (String key, {T fromJson(dynamic json)?, String separator = ','}) → List< T> ? -
Returns the value of
keyas a list, ornullif it isn't set or an item can't be converted. -
maybeGetMap(
String key) → Map< String, dynamic> ? -
Returns the value of
keyparsed as a JSON object, ornull. -
maybeGetNum(
String key) → num? -
Returns the value of
keyas anum, ornullif it isn't set or isn't a number. -
maybeGetObject<
T> (String key, {required T fromJson(dynamic json)}) → T? -
Returns the value of
keyparsed as JSON and converted withfromJson, ornullif it isn't set, isn't valid JSON, orfromJsonthrows. -
maybeGetString(
String key) → String? -
Returns the value of
key, ornullif it isn't set. -
maybeGetUri(
String key) → Uri? -
Returns the value of
keyas a Uri, ornullif it isn't set or can't be parsed. -
missingKeys(
Iterable< String> keys) → List<String> -
Keys of
keyswithout a non-empty value. -
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