I'm implementing a DataTable
to show some data, to do this I'm using a PaginatedDataTable
, so I can load and show my data, the problem is that my DataTable
shows a CheckBox per row and I don't want it.
This is my current result:
I want remove these CheckBox but I not have idea how to do it.
Code:
ExpensesDataSource _expensesDataSource = ExpensesDataSource([expense]);
Widget getDataTable() {
return PaginatedDataTable(
header: Text('Despesas', style: TextStyle(color: Color(0xFF4C4C4C), fontWeight: FontWeight.bold, fontSize: 15),),
columns: <DataColumn>[
DataColumn(
label: Text("Data"),
numeric: false,
),
DataColumn(
label: Text("Descrição"),
numeric: false,
),
DataColumn(
label: Text("Total"),
numeric: false,
),
],
source: _expensesDataSource,
);
}
class ExpensesDataSource extends DataTableSource {
List<Expense> _expenses = <Expense>[];
int _selectedCount = 0;
ExpensesDataSource(List<Expense> listExpenses) {
this._expenses = listExpenses;
}
@override
DataRow getRow(int index) {
final Expense expense = _expenses[index];
return DataRow.byIndex(
index: index,
onSelectChanged: (bool value) {
print('Row selected: $value ${expense.name}');
},
cells: [
DataCell(Text(expense.date)),
DataCell(Text(expense.name)),
DataCell(Text(Utils.convert2currency(expense.total_amount)))
]
);
}
@override
// TODO: implement rowCount
int get rowCount => _expenses.length;
@override
bool get isRowCountApproximate => false;
@override
int get selectedRowCount => _selectedCount;
}