check method
Check if the condition is satisfied by passing data
.
When DynamicMap is passed, the value for key is checked.
If [List]' is passed, it checks whether or not the elements of the list satisfy the condition, and returns
true` if one of them satisfies the condition.
All other values are checked to see if they satisfy the condition themselves, regardless of key.
Implementation
bool check(Object? data) {
if (data == null) {
return false;
}
if (data is DynamicMap) {
if (key.isEmpty) {
return false;
}
if (!data.containsKey(key)) {
return false;
}
return _check(data[key]);
} else if (data is List) {
return data.any((element) => check(element));
} else {
return _check(data);
}
}