我需要使TableRow可单击并导航到其他屏幕,但我不能用GestureDetector或Inkwell Package TableRow。如何使TableRow可单击。我已经实现了如下:
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,
),
]),
字符串
3条答案
按热度按时间5fjcxozz1#
我觉得你做不到,
您可以使用DataTable来代替Tablewidget,它一定能满足您的需求。
在DataRow中有一个名为onSelectChanged的属性,这正是您想要的。
mspsb9vt2#
不是针对整行,而是针对行中的单个单元格,您可以使用TableRowInkWell。TableRowInkWell进入TableRow本身, Package 一个子级。以下是答案,并归功于SoloWofl93:How to use TableRowInkWell inside Table in flutter?
字符串
o0lyfsai3#
这是不可能实现的,因为
TableRow
不是一个小部件,因此它不能被 Package 在其他小部件中,如InkWell
。This answer是目前最好的选择。
您可以尝试的一个可能的解决方案是使用堆栈小部件在目标
TableRow
的顶部添加一个大小完全相同的InkWell
。但这将是难以实施的,这不是一个干净的做法。或者,您可以在表中需要处理抽头的每个单元格中保留
InkWell
,这将是多余的在这个SO answer中有一个可能的解决方案。我还没试过呢。