When you have tabular data to show in application use
DataTable. It allows you to build a table that automatically resizes its columns according to what’s in the cells.
First, add the
DataTable() widget and define its columns. Next, define each row and the cells in each of them. And you have a DataTable.
SingleChildScrollView( padding: const EdgeInsets.all(8.0), child: DataTable(sortColumnIndex: 2, sortAscending: true, columns: [ DataColumn(label: Text('Item Code')), ..... ], rows: [ DataRow(selected: true, cells: [ DataCell(Text('EL-7861')), ..... ])),
It’s possible that all of your data won’t fit in the horizontal space for example, on small phones, wrap the widget with a
DataTable(sortColumnIndex: 2, sortAscending: true) DataCell(Text('Place holder'), placeholder: true,showEditIcon: true)
You can sort data in DataTable. You can make a column numerical to forcing right alignment in left to right locals. You can show that a row is selected. You can show that a cell is editable or not yet filled in(Placeholder).
In Flutter everything is a widget, feel free to put any widget into your data cells. All the elements of the DataTable provide friendly callbacks, so you can implement how the user should edit, select, or sort the data.