I have a DataTable
widget for displaying some data in tabular format. I wasn't able to find any way to change the background color of the DataColumn
, it defaults to white.
I tried wrapping the label
inside a Container
but that does not help since the container takes the dimensions of the child.
Is there any easier way to set the background color of `DataColum'?
Below is some code for reference -
DataTable(
dataRowHeight: 70,
headingRowHeight: 60,
rows: List.generate(4, (index) {
return DataRow(
cells: <DataCell>[
DataCell(
Text("Number",),
),
DataCell(
Text(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
),
),
]
);
}),
columns: [
DataColumn(
label: Text("Name"),
),
DataColumn(
label: Text("Description"),
),
],
)
What you can do is create a "color" property (not required to set any value for it) in Zone class. Then set the color property of RaisedButton to zone.
Now in flutter version 1.22, you can do it like this
DataTable(
headingRowColor:
MaterialStateColor.resolveWith((states) => Colors.blue),
columns: [
DataColumn(),
DataColumn(),
],
rows: [
DataRow(
cells: [
DataCell(),
DataCell(),
],
),
],
)
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