extractMapList static method
Extracts and maps a list of objects, skipping any entry that is not a map.
The tolerant behaviour matters here: a model asked for ten items will occasionally emit nine objects and a stray string, and losing the nine is worse than dropping the one.
Implementation
static List<Map<String, Object?>> extractMapList(String text) {
final list = extractList(text) ?? const [];
return [
for (final entry in list)
if (entry is Map) entry.cast<String, Object?>(),
];
}