Handle tap in Flutter TableRow

Issue

I need to make the TableRow clickable and navigate to other screen but I cannot wrap TableRow with GestureDetector or Inkwell. How can I make the TableRow clickable. I have implemented as follows:

for (int i = 0; i < menuList.length; i++)
              TableRow(children: [
                SizedBox(
                  width: 5,
                ),
                Text((i + 1).toString()),
                Text(menuList[i].name),
                Text(menuList[i].price.toString()),
                Text(menuList[i].maxQty.toString()),
                menuList[i].status == 0
                    ? Text(
                        menuList[i].foodStatus,
                        style: TextStyle(color: Colors.red),
                      )
                    : YourListViewItem(
                        id: menuList[i].id,
                        index: menuList[i].status,
                      ),
              ]),

Solution

I don’t think you can do this,

You can use DataTable instead of Table widget, it will definitely meet your need.

In DataRow there is a property named onSelectChanged, This is
exactly what you want.

Answered By – farouk osama

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.