upsert method
void
upsert({
- required TK key,
- TV value(
- TV item
- required TV defaultValue,
- bool overwrite = true,
if key present, overwrites value, if overwriteValue set, else inserts
Implementation
void upsert({
required TK key,
TV Function(TV item)? value,
required TV defaultValue,
bool overwrite = true,
}) {
if (!containsKey(key)) {
this[key] = defaultValue;
} else {
if (!overwrite) {
return;
}
}
if (value != null && containsKey(key)) {
this[key] = value(this[key] as TV);
}
}