I need Datatable to stretch to max width, but right now it looks like this.
I've tried to use ConstrainedBox, but it didn't work out and showed me an error
SingleChildScrollView _dataBody() {
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
headingRowColor:
MaterialStateColor.resolveWith((states) => Color(0xFF2F80ED)),
headingTextStyle: TextStyle(color: Colors.white),
columns: [
DataColumn(label: Text('ID')),
DataColumn(label: Text('Name')),
DataColumn(label: Text('Surname')),
DataColumn(label: Text('Birth date')),
DataColumn(label: Text('Algebra')),
DataColumn(label: Text('Chemistry')),
DataColumn(label: Text('Programing'))
],
rows: _students
.map((student) => DataRow(cells: [
DataCell(Text(student.id)),
DataCell(Text(student.firstName.toString())),
DataCell(Text(student.lastName.toString())),
DataCell(Text(student.birthDate.toString())),
DataCell(Text(student.algebra.toString())),
DataCell(Text(student.chemistry.toString())),
DataCell(Text(student.programing.toString()))
]))
.toList()),
),
);
}
this is the part where I implement my table:
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
height: 110,
child: Container(),
),
Expanded(
child: _dataBody(),
)
],
))