objDeleteKeyByValue
Deletes keys equal to the given value from the object data. If the recursive option is trueTrue, also deletes all keys corresponding to the same value in the child items.
Parameters
| Name | Type | Required | Default |
|---|---|---|---|
obj | objectMap<String, dynamic>dict | ● | – |
searchValue | string | number | nulldynamicstr | int | None | – | – |
recursive named keyword | booleanbool | – | falseFalse |
namedThese parameters are passed as named parameters.
keywordThese parameters are passed as keyword arguments, or as a single dict in their place.
Returns
object | null
Map<String, dynamic>?
dict | None
Examples
javascript
const result = objDeleteKeyByValue(
{
a: 1,
b: 2,
c: {
aa: 2,
bb: {
aaa: 1,
bbb: 2
}
},
d: {
aa: 2
}
},
2,
true
);
console.log(result); // Returns { a: 1, c: { bb: { aaa: 1 } }, d: {} }dart
print(objDeleteKeyByValue(
{
'a': 1,
'b': 2,
'c': {
'aa': 2,
'bb': {
'aaa': 1,
'bbb': 2
}
},
'd': {
'aa': 2
}
},
2,
recursive: true
));
// Returns { 'a': 1, 'c': { 'bb': { 'aaa': 1 } }, 'd': {} }python
result = objDeleteKeyByValue(
{
'a': 1,
'b': 2,
'c': {
'aa': 2,
'bb': {
'aaa': 1,
'bbb': 2
}
},
'd': {
'aa': 2
}
},
2,
True
)
print(result) # Returns { 'a': 1, 'c': { 'bb': { 'aaa': 1 } }, 'd': {} }