How to hide DataTable's column header in Flutter?

Viewed 3385

How to hide the columns header of DataTable in Flutter?
DataTable in Flutter

DataTable(
  headingRowHeight: 0,
  columns: <DataColumn>[
  DataColumn(label: Text("Name")),
  DataColumn(label: Text("Hour")),
  DataColumn(label: Text("Tag")),
  DataColumn(label: Text("Date")),
  DataColumn(label: Text("Action")),

], rows: lstCourse.map((e) => DataRow(
  cells: <DataCell>[
    DataCell(Text(e.Name)),
    DataCell(Text(e.Hour_Text)),
    DataCell(Text(e.Tag)),
    DataCell(Text(e.StartDate_Text)),
    DataCell(RaisedButton(onPressed: (){}, child: Text("Đăng ký"),)),
  ]
)).toList()
);

I have try to find some option in DataTable class but seem not exist

4 Answers

headingRowHeight to 0, empty container to DataColumn label

DataTable(
         headingRowHeight: 0,
         columns: [
           DataColumn(label: Container()),
           DataColumn(label: Container()),
           DataColumn(label: Container()),
           DataColumn(label: Container()),
           DataColumn(label: Container()),
         ],
         rows: ..
    ),

Set headingRowHeight to 0 and all label text to be empty string DataColumn(label: Text("")).

DataTable(
                headingRowHeight: 0,
                  columns: const [
                DataColumn(
                    label: Text(''),
                ),
                DataColumn(
                    label: Text('')),
                DataColumn(
                    label: Text('')),
                DataColumn(
                    label: Text('')),
                DataColumn(
                    label: Text('')),
              ],

Combine headingRowHeight:0 and Text("")

if (your condition) DataColumn( label: Text('your column name')),

Related