isTabularArray function
Checks if an array can be represented as a tabular format
Implementation
bool isTabularArray(List<Map<String, Object?>> rows, List<String> header) {
for (final row in rows) {
final keys = row.keys;
// All objects must have the same keys (but order can differ)
if (keys.length != header.length) {
return false;
}
// Check that all header keys exist in the row and all values are primitives
for (final key in header) {
if (!row.containsKey(key)) {
return false;
}
if (!isJsonPrimitive(row[key])) {
return false;
}
}
}
return true;
}