Renders style-able flex ascii tables.
- Customizable table borders
- Multiline rows
- Column size control
- Min and max Column widths
- Flex column widths
- Percentage based column widths
- Cell text alignment
- Cell padding
- Merged cells
- Text truncation and ellipsis
import 'package:text_table/text_table.dart';
main() {
final tab = TableRenderer().render([
['Messi', 'Barcelona FC', 80],
['Christiano Ronaldo', 'Real Madrid', 30],
['Luiz Suarez', 'Barcelona FC', 50]
], columns: [
'Player',
'Team',
'Goals'
]);
print(tab);
}
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโ
โ Player โ Team โGoalsโ
โโโโโโโโโโโโโโโโโโโโฟโโโโโโโโโโโโโฟโโโโโโฅ
โMessi โBarcelona FCโ80 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโค
โChristiano RonaldoโReal Madrid โ30 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโค
โLuiz Suarez โBarcelona FCโ50 โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโ
final tab = TableRenderer().render([
['Messi', 'Barcelona FC', 80],
['Christiano Ronaldo', 'Real Madrid', 30],
['Luiz Suarez', 'Barcelona FC', 50]
], columns: [
ColSpec(name: 'Player', width: Fixed(25), align: Align.left),
ColSpec(name: 'Team', width: Fixed(25), align: Align.center),
ColSpec(name: 'Goals', width: Fixed(10), align: Align.right)
]);
print(tab);
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโ
โ Player โ Team โ Goals โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฟโโโโโโโโโโโโโโโโโโโโโโโโโโฟโโโโโโโโโโโฅ
โMessi โ Barcelona FC โ 80โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโค
โChristiano Ronaldo โ Real Madrid โ 30โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโค
โLuiz Suarez โ Barcelona FC โ 50โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโ
import 'package:text_table/text_table.dart';
main() {
final tab = TableRenderer(padding: Padding.same(1)).render([
['Messi', 'Barcelona FC', 80],
['Christiano Ronaldo', 'Real Madrid', 30],
['Luiz Suarez', 'Barcelona FC', 50]
], columns: [
'Player',
'Team',
ColSpec(name: 'Goals', padding: Padding.same(2)),
]);
print(tab);
}
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโ
โ Player โ Team โ Goals โ
โโโโโโโโโโโโโโโโโโโโโโฟโโโโโโโโโโโโโโโฟโโโโโโโโโโฅ
โ Messi โ Barcelona FC โ 80 โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโค
โ Christiano Ronaldo โ Real Madrid โ 30 โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโค
โ Luiz Suarez โ Barcelona FC โ 50 โ
โโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโ
import 'package:text_table/text_table.dart';
main() {
final tab = TableRenderer(padding: Padding.same(2)).render([
['Messi', 'Barcelona FC', 80],
['Christiano Ronaldo', 'Real Madrid', 30],
['Luiz Suarez', 'Barcelona FC', 50]
], columns: [
ColSpec(name: 'Player', width: Flex(2)),
ColSpec(name: 'Team', width: Flex(1), minWidth: Fixed(15)),
ColSpec(name: 'Goals', width: Flex(1), align: Align.right)
], width: 50);
print(tab);
}
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโ
โ Player โ Team โ Goals โ
โโโโโโโโโโโโโโโโโโโฟโโโโโโโโโโโโโโโโโโโโฟโโโโโโโโโโโฅ
โ Messi โ Barcelona FC โ 80 โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโค
โ Christiano Ro โ Real Madrid โ 30 โ
โ naldo โ โ โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโค
โ Luiz Suarez โ Barcelona FC โ 50 โ
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโ
Use border
field of TableRenderer
to customize the border style of the table.
final tab = TableRenderer(border: Border.doubleLines)
.render(rows, columns: columns);
print(tab);
โโโโโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโคโโโโโโ
โ Player โ Team โGoalsโ
โ โโโโโโโโโโโโโโโโโโโชโโโโโโโโโโโโโชโโโโโโฃ
โMessi โBarcelona FCโ80 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโข
โChristiano RonaldoโReal Madrid โ30 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโข
โLuiz Suarez โBarcelona FCโ50 โ
โโโโโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโงโโโโโโ
final tab =
TableRenderer(border: Border.compact).render(rows, columns: columns);
print(tab);
Player Team Goals
-------------------------------------
Messi Barcelona FC 80
Christiano Ronaldo Real Madrid 30
Luiz Suarez Barcelona FC 50
final tab =
TableRenderer(border: Border.round).render(rows, columns: columns);
print(tab);
โญโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโฎ
โ Player โ Team โGoalsโ
โโโโโโโโโโโโโโโโโโโโฟโโโโโโโโโโโโโฟโโโโโโฅ
โMessi โBarcelona FCโ80 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโค
โChristiano RonaldoโReal Madrid โ30 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโค
โLuiz Suarez โBarcelona FCโ50 โ
โฐโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโฏ