Source
List<List> get rows {
int colLen = -1;
if (columns != null) {
colLen = columns.length;
}
if (_rows == null) {
_rows = [];
if (updates == null) {
return _rows;
}
for (Object obj in updates) {
List<dynamic> row;
if (obj is List) {
if (obj.length < colLen) {
row = obj.toList();
for (int i = obj.length; i < colLen; ++i) {
row.add(columns[i].defaultValue);
}
} else if (obj.length > colLen) {
if (colLen == -1) {
// when column is unknown, just return all values
row = obj.toList();
} else {
row = obj.sublist(0, colLen);
}
} else {
row = obj;
}
} else if (obj is Map) {
row = [];
if (columns == null) {
Map map = obj;
List<String> keys = map.keys.map((k) => k.toString()).toList();
columns = keys.map((x) => new TableColumn(x, "dynamic")).toList();
}
if (columns != null) {
for (TableColumn column in columns) {
if (obj.containsKey(column.name)) {
row.add(obj[column.name]);
} else {
row.add(column.defaultValue);
}
}
}
}
_rows.add(row);
}
}
return _rows;
}