首页 > 解决方案 > Flutter 数据表问题

问题描述

我想在 DataTable 中为 DataRow 实现可关闭或滑动操作。到目前为止,我只能在列表中找到主要使用/显示的此类功能。我使用 DataTable 的原因是因为我想显示水平滚动可用数据列表并显示为数据表样式。这是我的代码,如果有任何可用的指针,我将不胜感激。

    SingleChildScrollView(
      scrollDirection: Axis.horizontal,
      child: DataTable(
        columns: [
          DataColumn(label: Text('Date')),
          DataColumn(label: Text('Customer')),
          DataColumn(label: Text('Amount'), numeric: true),
          DataColumn(label: Text('Remark')),
        ],
        rows: snapshot.data
            .map(
              (item) => DataRow(
                cells: [
                  DataCell(Text(
                      DateFormat('yyyy/MM/dd').format(item.date))),
                  DataCell(Text(item.customerName)),
                  DataCell(
                      Text(NumberFormat().format(item.amount))),
                  DataCell(Text(item.remark)),
                ],
              ),
            )
            .toList(),
      ),
    ),

谢谢!

标签: flutterdart

解决方案


推荐阅读