updateDeeply function
dynamic
updateDeeply(])
set at keyPath
of data
the value of updater
-function with value of data
at keyPath
or notSetValue
as argument
Implementation
dynamic updateDeeply(List keyPath, dynamic data, Function updater,
[dynamic notSetValue, int i = 0]) {
if (i == keyPath.length) {
return updater(data == null ? notSetValue : data);
}
if (!(data is Map)) {
data = {};
}
data = Map<dynamic, dynamic>.from(data);
data[keyPath[i]] =
updateDeeply(keyPath, data[keyPath[i]], updater, notSetValue, ++i);
return data;
}