deepCopyMap function
Deep copy for maps and lists.
deepCopyMap and deepCopyList recurse to the input's nesting depth, so they are not intended for untrusted, arbitrarily-deep structures.
Implementation
Map<String, dynamic> deepCopyMap(Map<String, dynamic> source) {
final Map<String, dynamic> out = <String, dynamic>{};
for (final MapEntry<String, dynamic> e in source.entries) {
final v = e.value;
if (v is Map<String, dynamic>) {
out[e.key] = deepCopyMap(v);
} else if (v is List<dynamic>) {
out[e.key] = deepCopyList(v);
} else {
out[e.key] = v;
}
}
return out;
}