0

I'm currently using a DataTable to display a summary of some data like this

DataTable(
    showCheckboxColumn: false,
    columns: columnNames,
    rows: state.alerts.alerts
        .map(
          (alert) => DataRow(
            cells: [
              const DataCell(Icon(
                Icons.circle,
                color: Colors.amber,
              )),
              const DataCell(Text("Something"),),
              const DataCell(Text("Something")),
              const DataCell(Text("TO DO")),
              DataCell(Text(DateTime.fromMillisecondsSinceEpoch(alert.time.toInt(), isUtc: true).toString())),
            ],
            onSelectChanged: (bool? selected) {
              
              if (selected == null || !selected) return;
              
              // Show details
            },
          ),
        )
        .toList())

Which looks something like this enter image description here

I would like to have it so when a user selects a row, that row expands vertically and shows additioal information whilst still part of the table (i.e. all rows below the selected row should be pushed down). The functionality I'd like to achieve is exactly what https://api.flutter.dev/flutter/material/ExpansionPanelList-class.html is intended for however using that would mean I loose access to the advantages of using a table (automated column sizing etc).

Is there a way I can create a custom table row without copying the entire DataTable source out and modifying how rows are generated?

^EDIT: After looking into the source of DataTable this doesn't look like a viable option, DataTable ultimatly mashes everything into a Table which enforces column widths. The only work around I can think of would be creating a new table for each row so a non tabled widget can be inserted in between but this would likely break a lot of stuff and be horrible for performance.

Expandable row in table with flutter- is it possible? looks like a step in the right direction however much like the OP, I can't see a way to apply Expandable to a TableRow rather than a TableCell

Thanks

Darc
  • 745
  • 10
  • 26
  • I've achieved something close to the result I want by modifying ExpansionPanelList although it feels a bit hacky. If someone knows a way to do this with a proper table I'd still be interested – Darc Jun 19 '22 at 12:03

0 Answers0