has static method

bool has(
  1. Map map,
  2. String key
)

Returns true when map has a value at key (dot notation).

Implementation

static bool has(Map map, String key) {
  if (key.isEmpty) return false;
  if (map.containsKey(key)) return true;
  dynamic current = map;
  for (final segment in key.split('.')) {
    if (current is Map && current.containsKey(segment)) {
      current = current[segment];
    } else if (current is List) {
      final idx = int.tryParse(segment);
      if (idx == null || idx < 0 || idx >= current.length) return false;
      current = current[idx];
    } else {
      return false;
    }
  }
  return true;
}