asString method
Retrieves the string value associated with the key
. If the key does not exist, returns the def
value.
key
The key in the map to retrieve the value from.
def
The default value to return if the key is not found. Defaults to an empty string.
Returns: The string value associated with the key
or def
if not found.
Implementation
String asString(String key, {String def = ''}) {
if (keys.contains(key)) {
return this[key] ?? def;
}
return def;
}