dictsToGrid static method
Convenience to build grid from array of HDict. Any null entry will be row of all null cells.
Implementation
static HGrid dictsToGrid(HDict meta, List<HDict> dicts) {
if (dicts.isEmpty) {
return HGrid(meta, [HCol(0, 'empty', HDict.EMPTY)], []);
}
HGridBuilder b = HGridBuilder();
b.meta.addDict(meta);
var colsByName = collectColumns(dicts).toList();
// if all dicts were null, handle special case
// by creating a dummy column
if (colsByName.isEmpty) {
colsByName.add('empty');
}
colsByName.forEach((name) => b.addCol(name));
// now map rows
dicts.forEach((dict) {
List<HVal?> cells = collectValues(dict, b._cols);
b._rows.add(cells);
});
return b.toGrid();
}