I need to hide columns in a flutter DataTable but cannot seem to find any examples on how to do so.
the following is the code snippet that i am using. Is there some way to set then to hidden or something.
When i remove the column completely i get an assertion that the row calls are not equal to the column count. So i am not sure what i should do? Any help is much appreciated.
child: DataTable(
columnSpacing: 10,
headingRowHeight: 30,
dataRowHeight: 30,
horizontalMargin: 0,
columns: [
DataColumn(
numeric: true,
label: Text('Id'),
),
DataColumn(
label: Text('Date'),
),
DataColumn(
label: Text('Amount'),
),
DataColumn(
label: Text('Type'),
),
DataColumn(
label: Text('Label'),
),
DataColumn(
label: Text('Category'),
)
],
rows: vm.transactionList
.map(
(tran) => DataRow(cells: [
DataCell(
Text(
tran.id.toString(),
),
),
DataCell(
Text(
tran.tranDate(),
),
),
DataCell(
Text(
tran.amount.toString(),
),
),
DataCell(
_getTransactionType(tran.type),
),
DataCell(
Text(
tran.label.toString(),
),
),
DataCell(
Icon(
tran.category.icon,
),
),
]),
)
.toList(),
),
I have been able to resolve this by actually removing the unneeded DataColumn and DataCell elements. I did not find any property that could be used to hide or make a column visible so removing them completely was the next best option.