findObjectsByKey function
Finds and returns Objects inside objectList
by its key
.
Implementation
List findObjectsByKey(List objectList, String key, {String? nested}) {
final List objects = [];
for (final item in objectList) {
var current = item as JsonMap;
if (nested != null) {
current = current[nested] as JsonMap;
}
if (current.containsKey(key)) {
objects.add(current);
}
}
return objects;
}