dot static method
Flattens a nested map into a single-level map keyed by dot-paths.
Source keys that already contain dots are kept verbatim, which means a
dot → undot round-trip is lossy when input keys contain ..
Obj.dot({'a': {'b': 1, 'c': 2}}); // {'a.b': 1, 'a.c': 2}
Implementation
static Map<String, dynamic> dot(Map map, [String prefix = '']) {
final result = <String, dynamic>{};
map.forEach((k, v) {
final key = prefix.isEmpty ? k.toString() : '$prefix.$k';
if (v is Map && v.isNotEmpty) {
result.addAll(dot(v, key));
} else {
result[key] = v;
}
});
return result;
}