【问题标题】:How to display data from MySQL database in table format in flutter application?如何在 Flutter 应用程序中以表格格式显示 MySQL 数据库中的数据?
【发布时间】:2021-02-13 15:19:40
【问题描述】:

这是我的代码。在这里,我使用了 Listview.builder,因为整个数据显示在 1 个表格单元中。我应该在 listview 的地方使用什么来在不同的单元格中正确显示数据。 或者任何其他方式从后端动态显示数据?

TableRow(children: [

              TableCell(
                child: FutureBuilder(
                  future: fetchProducts(),
                  builder: (context, snapshot){
                    if(snapshot.hasData) {
                      return ListView.builder(
                        itemCount: snapshot.data.length,
                        shrinkWrap: true,
                        itemBuilder: (BuildContext context, index){
                          Products product = snapshot.data[index];
                          return Text(//"Name      :- "
                    '${product.pname}', style: TextStyle(fontSize: 15));    
                  });
                }},
              )),]),

【问题讨论】:

    标签: flutter dart flutter-table


    【解决方案1】:

    使用 DataTable 代替 tablerow,它会自动调整大小,它具有列和行子级,因此它可能是显示数据的最佳方式,请查看此 youtube 视频 https://www.youtube.com/watch?v=ktTajqbhIcY&vl=en

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-23
      • 2019-08-20
      • 1970-01-01
      • 2010-10-30
      • 2013-06-23
      • 2013-10-28
      • 1970-01-01
      相关资源
      最近更新 更多