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, 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')))
])
]
),
);
Add columnSpacing
property to DataTable. By default it is set to 56.0.
columnSpacing: 30.0
use columnSpacing in the databale then set 1 this takes then length of column text
columnSpacing: 0,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With