addPathToMap function
adds a dynamic value
to Map<String, dynamic> yaml
with the depth definded
by List<String> keyPath
Implementation
Map<String, dynamic> addPathToMap(
Map<String, dynamic> map, List<String> keyPath, dynamic value) =>
keyPath.length == 1
? Map<String, dynamic>.from({...map, keyPath.first: value})
: Map<String, dynamic>.from({
...map,
keyPath.first:
addPathToMap(map[keyPath.removeAt(0)] ?? {}, keyPath, value)
});