rowRightAligned method
Implementation
PrintBuilder rowRightAligned(List<String> columns, List<int> widths, {FontSize fontSize = FontSize.normal}) {
if (columns.length != widths.length) {
throw ArgumentError('Columns and widths must have the same length');
}
int totalWidth = widths.fold(0, (sum, width) => sum + width);
if (totalWidth != 100) {
throw ArgumentError('Total width must equal 100%');
}
int maxChars = paperSize.getMaxChars(fontSize);
String line = '';
for (int i = 0; i < columns.length; i++) {
int colWidth = (maxChars * widths[i] / 100).floor();
String column = columns[i];
if (column.length > colWidth) {
column = '${column.substring(0, colWidth - 2)}..';
}
// Right-align the last column, others as specified
if (i == columns.length - 1) {
// Last column - right align
column = column.padLeft(colWidth);
} else {
// Other columns - left align but with proper spacing
column = column.padRight(colWidth);
}
line += column;
}
return text(line, fontSize: fontSize);
}