decodeStringMap static method

Map<String, String>? decodeStringMap(
  1. DartObject? obj
)

Decodes a Map<String, String> constant, or null when obj is absent or not a map.

Implementation

static Map<String, String>? decodeStringMap(DartObject? obj) {
  if (obj == null || obj.isNull) return null;

  final raw = obj.toMapValue();
  if (raw == null) return null;

  final values = <String, String>{};
  for (final entry in raw.entries) {
    final key = entry.key?.toStringValue();
    final value = entry.value?.toStringValue();
    if (key == null || value == null) continue;
    values[key] = value;
  }
  return values;
}