createTableRows function
Implementation
List<TRowElement> createTableRows(Object? rows, bool header) {
List<TRowElement> tableRows;
if (rows is Iterable) {
var rowsList = rows.toList();
if (listMatchesAll(rowsList, (dynamic e) => e is TRowElement)) {
return rowsList.whereType<TRowElement>().toList();
} else if (listMatchesAll(
rowsList, (dynamic e) => _domHTML.isHtmlNode(e))) {
var trList = rowsList.where((e) => _domHTML.getNodeTag(e) == 'tr');
var list =
trList.map((e) => DOMNode.from(e)).whereType<TRowElement>().toList();
return list;
} else if (listMatchesAll(rowsList, (dynamic e) => e is MapEntry)) {
var mapEntries = rowsList.whereType<MapEntry>().toList();
tableRows = mapEntries
.map((e) => createTableRow([e.key, e.value], header))
.toList();
} else if (rowsList.any((e) => e is List)) {
tableRows = [];
for (var rowCells in rowsList) {
var tr = createTableRow(rowCells, header);
tableRows.add(tr);
}
} else {
tableRows = [createTableRow(rowsList, header)];
}
} else {
tableRows = [createTableRow(rows, header)];
}
return tableRows;
}