如何在Flutter中更改DataTable的列宽?
问题描述:
我的Flutter应用中有一个DataTable.问题在于,填充数据时,列的宽度会自动设置,并且过大.如何手动设置列宽?我尝试更改窗口小部件构建"中的宽度参数,但它更改了整个表的宽度,而不是所需列的宽度.
I have a DataTable in my Flutter app. The problem is that when data is filled, the width of the columns is set automatically, and it too large. How can I manually set the column width? I tried to change the width parameters in the "Widget build", but it change the width of the whole table, but not a desired column.
答
@Smith,您是说不能这样做?如果您可以共享一些代码...
@Smith, you mean you can't do this ? if you could share some code ...
Widget build(BuildContext context) {
return Scaffold(
body: DataTable(
columns: [DataColumn(label: Text('label'))],
rows: [
DataRow(cells: [DataCell(
Container(
width: 200, //SET width
child: Text('text')))
])
]
),
);