Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen for tap on DataRow inside DataTable in Flutter

I was able to setup a DataTable to display a bunch of data. But want to navigate to another screen when a row is tapped.

Unfortunately there is no onTap callback for DataRow.

I ended up adding onTap for each DataCell which looks like a hacky solution. Is there any other way to handle this?

like image 707
Sreekanth Avatar asked Nov 16 '22 23:11

Sreekanth


1 Answers

The onTap call in DataRow is the onSelectChanged function

DataRow(
    cells: [
       DataCell(Text("ID"))
      ,DataCell(Text("NAME"))
    ],
    onSelectChanged: (value) {
     // insert your navigation function here and use the selected value returned by the function
      Navigator.of(context).pop(value);
    }
);
like image 189
Niccolò Carella Avatar answered Dec 05 '22 18:12

Niccolò Carella