onLongPress PaginatedDataTable DataRow

390 Views Asked by At

What is the best way to have an entire row trigger a callback when Long Pressing anywhere in it. Im using a PaginatedDataTable, which contains DataRow's of DataCell's.

The only way I found was by adding a TableRowInkWell or GestureDetector inside each DataCell but this doesn't work right, you need to actually long press on the text inside any of the cells to work.

Ive also tried adding padding to enlarge the selection area but that messed up the datatable itself.

      dataCells.add(DataCell(
        TableRowInkWell(
          onLongPress: () {
            // do something
          },
          onTap: () {
            // do something
          },
          child: ConstrainedBox(
            constraints: BoxConstraints(maxWidth: 150),
            child: Text(
              content,
              overflow: TextOverflow.fade,
              maxLines: 1,
              softWrap: false,
            ),
          ),
        ),
      ));

Also DataRow.byIndex doesn't have any callbacks other than onSelectChanged which works for onTap.

   return DataRow.byIndex(
        onSelectChanged: (bool value) {
          // do something
        },
        index: index,
        cells: dataCells
    );
0

There are 0 best solutions below