getString static method

String? getString(
  1. Map map,
  2. String key, [
  3. String? defaultValue
])

Returns the value at key coerced to String, or defaultValue.

Strings pass through; everything else is rendered with toString(). Returns defaultValue when the path is missing or the value is null.

Implementation

static String? getString(Map map, String key, [String? defaultValue]) {
  final v = get(map, key);
  if (v == null) return defaultValue;
  if (v is String) return v;
  return v.toString();
}