remove static method
dynamic
remove(
- Data mapOrList,
- dynamic value, {
- bool notify = true,
- bool findValue = false,
})
Implementation
static dynamic remove(
Data mapOrList,
dynamic value, {
bool notify = true,
bool findValue = false,
}) {
if (value is Data) throw Exception('Cannot remove a RecipeValue');
dynamic result;
if (mapOrList.value is Map) {
if (findValue) {
mapOrList.value.removeWhere((k, v) => value == v);
} else {
result = mapOrList.value.remove(value);
}
} else if (mapOrList.value is List) {
if (findValue) {
(mapOrList.value).removeWhere((v) => v._value == value);
} else {
if (value! is int) value = int.tryParse(value);
result = (mapOrList.value).removeAt(value);
}
} else {
throw Exception('Not a map or list');
}
if (notify) mapOrList.notifyListeners();
return result;
}