How to hide DataTable's column header in Flutter?

2,361

Solution 1

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: ..
    ),

Solution 2

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

Share:
2,361
phuongnd
Author by

phuongnd

Just another guy from Vietnam

Updated on December 18, 2022

Comments

  • phuongnd
    phuongnd over 1 year

    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

  • Jani
    Jani over 2 years
    The first divider remains there, so I also used dividerThickness: double.minPositive to get rid of all the dividers. I don't have any idea how to get rid of only the very first divider though.