Table Widget可以在app的页面上实现table的效果。
border可以给table添加线。IntrinsicColumnWidth可以让children里面的元素里的宽度按照Container里指定的宽度来排列。
如果不设置IntrinsicColumnWidth的话, 就会自动把children元素占满屏幕。(Container里面设置的宽度其实是无效的。)
注意Table里面如果有多个TableRow的话,TableRow里面的children的个数要相等。
body: Table(
border: TableBorder.all(),
columnWidths: const {
0: IntrinsicColumnWidth(),
1: IntrinsicColumnWidth(),
// 2: IntrinsicColumnWidth(),
2: FlexColumnWidth()
},
children: [
TableRow(
children: [
Container(
width: 50,
height: 50,
color: Colors.red,
),
Container(
width: 50,
height: 50,
color: Colors.blue,
),
Container(
width: 50,
height: 50,
color: Colors.green,
)
]
),
TableRow(
children: [
Container(
width: 50,
height: 50,
color: Colors.red,
),
Container(
width: 50,
height: 50,
color: Colors.blue,
),
Container(
width: 50,
height: 50,
color: Colors.green,
)
]
)
],
)