buildTableTotals function
Implementation
pw.Widget buildTableTotals(pw.Context context, DocumentOptions options, List concepts) {
const tableHeaders = [ 'CONCEPTO', 'VALOR' ];
return pw.TableHelper.fromTextArray(
border: null,
cellPadding: const pw.EdgeInsets.only(left: 8, right: 8),
cellAlignment: pw.Alignment.centerLeft,
headerDecoration: const pw.BoxDecoration(
borderRadius: pw.BorderRadius.vertical(top: pw.Radius.circular(8)),
color: PdfColors.blueGrey50,
),
headerHeight: 25,
cellHeight: 20,
cellAlignments: {
0: pw.Alignment.centerLeft,
1: pw.Alignment.centerRight,
},
headerStyle: pw.TextStyle(
color: options.textColor,
fontSize: 10,
fontWeight: pw.FontWeight.bold,
),
cellStyle: pw.TextStyle(
color: options.textColor,
fontSize: 10,
),
rowDecoration: pw.BoxDecoration(
border: pw.Border(
bottom: pw.BorderSide(
color: options.surfaceColor,
width: .5,
),
),
),
headers: List<String>.generate(
tableHeaders.length,
(col) => tableHeaders[col],
),
data: List<List<String>>.generate(
concepts.length,
(row) => List<String>.generate(
tableHeaders.length,
(col){
Map concept = concepts[row] ?? {};
switch (col) {
case 0: return concept['name'] ?? '';
case 1: return (concept['amount'] ?? 0).toString();
default: return '';
}
}
),
),
);
}