FespTableData constructor
FespTableData({})
Implementation
FespTableData({
this.emptyCell = '-',
this.rowHeightByIndex,
this.colWidthByIndex,
this.gap = const Size(0, 0),
this.rows,
this.fromDict,
this.firstCell = '-',
required this.builder,
}) : assert((rows == null || fromDict == null),
'One of them rows || fromDict must be != null') {
if (fromDict == null) {
verticalMaxCount = rows!.length;
int maxCount = 0;
for (var e in rows!) {
if (e.length > maxCount) maxCount = e.length;
}
horizontalMaxCount = maxCount;
} else {
rows = [];
final List<Object> verticalHeaders = fromDict!.entries
.map(
(e) => e.key,
)
.toList();
final Set<Object> horizontalHeaders = {};
final entries = fromDict!.entries;
int maxCount = 0;
for (var e in entries) {
if (e.value.length > maxCount) maxCount = e.value.length;
horizontalHeaders.addAll(e.value.keys);
}
verticalMaxCount = entries.length + 1;
horizontalMaxCount = maxCount + 1;
final horizontalHeadersList = horizontalHeaders.toList();
rows!.addAll([
[firstCell, ...horizontalHeadersList]
]);
for (var v in verticalHeaders) {
final List<dynamic> row = [];
final dict = fromDict!;
for (var i = 0; i < horizontalHeadersList.length; i++) {
final h = horizontalHeadersList[i];
if (dict[v]!.containsKey(h)) {
row.add(dict[v]![h]!);
} else {
row.add(null);
}
}
rows!.add([v, ...row]);
}
}
}