buildTableTaxes function
Implementation
pw.Widget buildTableTaxes(pw.Context context, DocumentOptions options, String title, List taxes) {
List tableHeaders = [ title, '%', 'BASE', '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,
2: pw.Alignment.centerRight,
3: 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(
taxes.length,
(row) => List<String>.generate(
tableHeaders.length,
(col){
Tax tax = Tax.fromObject(taxes[row]);
switch (col) {
case 0: return tax.getName();
case 1: return tax.getPercent().toString();
case 2: return tax.getBase().toString();
case 3: return tax.getAmount().toString();
default: return '';
}
}
),
),
);
}