【问题标题】:How do I combine three lists in Flutter/Dart?如何在 Flutter/Dart 中合并三个列表?
【发布时间】:2021-12-23 00:49:51
【问题描述】:

我想合并三个列表,我的列表:

var px = [0.1, 0.2, 0.3];
var x = [0, 1, 2];
var mutiply = [0, 0.2, 0.6];

如何组合这三个列表?我想用 ListView 将所有列表数据检索到一个表中。

我想这样表示数据:

请指导我怎么做!谢谢!

【问题讨论】:

    标签: flutter dart listview datatable


    【解决方案1】:

    在这种情况下,您可以使用DataTable

    您可以配置其他属性。

     DataTable(
                headingRowColor:
                    MaterialStateProperty.all(Colors.blueGrey.withOpacity(.5)),
                showBottomBorder: true,
                columns: const [
                  DataColumn(
                    label: Text("x"),
                  ),
                  DataColumn(
                    label: Text("p(x)"),
                  ),
                  DataColumn(
                    label: Text("x*p(x)"),
                  ),
                ],
                rows: [
                  DataRow(cells: [
                    DataCell(Text(x[0].toString())),
                    DataCell(Text(px[0].toString())),
                    DataCell(Text(mutiply[0].toStringAsFixed(3))),
                  ]),
                  DataRow(cells: [
                    DataCell(Text(x[1].toString())),
                    DataCell(Text(px[1].toString())),
                    DataCell(Text(mutiply[1].toStringAsFixed(3))),
                  ]),
                  DataRow(cells: [
                    DataCell(Text(x[2].toString())),
                    DataCell(Text(px[2].toString())),
                    DataCell(Text(mutiply[2].toStringAsFixed(3))),
                  ]),
                ],
              ),
        
    

    【讨论】:

    • 你能帮帮我吗,拜托!!如果列表长度来自用户输入,那么我如何将数据检索到表中,帮助我兄弟
    • 取决于场景,您可以为此使用地图/生成功能。事实上,值取决于行,例如 x= [0,1,2] 将被构造为行而不是列,您还可以根据用户输入在动态 DataTable 上创建/查找单独的问题。
    • 如果您需要帮助,请随时询问。
    • 我可以私下联系你吗?
    • 我发布了一个新问题,请检查
    猜你喜欢
    • 2014-03-16
    • 1970-01-01
    • 2023-01-30
    • 1970-01-01
    • 2020-12-23
    • 2021-09-04
    • 2021-05-20
    • 1970-01-01
    • 2023-03-15
    相关资源
    最近更新 更多