findObjectByKey function
Finds and returns an Object inside objectList
by its key
.
Implementation
JsonMap? findObjectByKey(
List objectList,
String key, {
String? nested,
bool isKey = false,
}) {
for (final item in objectList) {
var current = item as JsonMap;
if (nested != null) {
current = current[nested] as JsonMap;
}
if (current.containsKey(key)) {
return (isKey ? current[key] : current) as JsonMap?;
}
}
return null;
}