changesOf method
Map
changesOf(
- Map newData, [
- bool includeNonExistingKeys = false,
- bool testFunc(
- dynamic
)?
])
Implementation
Map changesOf(Map newData, [
bool includeNonExistingKeys = false,
bool Function(dynamic)? testFunc,
]) {
if (newData.isEmpty) return {};
bool Function(dynamic) isDataEmpty = testFunc ?? __isDataEmpty;
Map changes = {};
for (String key in newData.keys) {
if (!includeNonExistingKeys && !data.containsKey(key)) continue;
dynamic oldValue = data[key];
dynamic newValue = newData[key];
if (isDataEmpty(oldValue) && isDataEmpty(newValue)) continue;
if (data[key] != newData[key]) {
changes[key] = newData[key];
}
}
return changes;
}