【问题标题】:Handle tap in Flutter TableRow在 Flutter TableRow 中处理水龙头
【发布时间】:2020-08-04 12:49:52
【问题描述】:

我需要使 TableRow 可点击并导航到其他屏幕,但我无法使用 GestureDetector 或 Inkwell 包装 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,
                      ),
              ]),

【问题讨论】:

  • 完整代码会有帮助....

标签: flutter flutter-table


【解决方案1】:

我认为你做不到,

你可以用DataTable代替Table小部件,它一定能满足你的需要。

DataRow中有一个名为onSelectChanged的属性,这是 正是你想要的。

【讨论】:

    【解决方案2】:

    不是整行,而是一行中的单个单元格,您可以使用 TableRowInkWell。 TableRowInkWell 进入 TableRow 本身,包裹一个孩子。这是答案,归功于 SoloWofl93:How to use TableRowInkWell inside Table in flutter?

    Table(
      border: TableBorder.all(),
      children: [
        TableRow(children: [
         
          // HERE IT IS...
          TableRowInkWell(
            onTap: (){},
            child: Column(children: [
              Icon(
                Icons.account_box,
                size: iconSize,
              ),
              Text('My Account'),
            ]),
          ),
         
          Column(children: [
            Icon(
              Icons.settings,
              size: iconSize,
            ),
            Text('Settings')
          ]),
        ]),
      ],
    )
    

    【讨论】:

    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    • 答案增强,请重新审核。
    【解决方案3】:

    这似乎是不可能的。

    您可以尝试的一件事是使用堆栈小部件将墨水池添加到原始表格顶部大小完全相同的表格行。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    相关资源
    最近更新 更多