class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Table(
columnWidths: const <int, TableColumnWidth>{
0: FixedColumnWidth(50.0),
1: FixedColumnWidth(50.0),
},
border: TableBorder.all(
color: Colors.black87, width: 2.0, style: BorderStyle.solid),
children: const <TableRow>[
TableRow(
children: <Widget>[
Text('Name'),
Text('Age'),
],
),
TableRow(
children: <Widget>[
Text('Tom'),
Text('20'),
],
),
],
),
);
}
}
columnWidths為指定索引及固定列宽;border為設定表格樣式。