setValue method
void
setValue(
- Map<String, dynamic> destination,
- String key,
- dynamic value
)
Implementation
void setValue(Map<String, dynamic> destination, String key, dynamic value) {
final path = key.split('.');
if (path.length > 1) {
var map = destination[path[0]];
if (map == null) {
map = <String, dynamic>{};
destination[path[0]] = map;
}
for (var i = 1; i < path.length - 1; i++) {
var nextMap = map[path[i]];
if (nextMap == null) {
nextMap = <String, dynamic>{};
map[path[i]] = nextMap;
}
map = nextMap;
}
map[path.last] = value;
return;
}
destination[key] = value;
}