如何在flutter应用程序中以表格格式显示MySQL数据库中的数据



这是我的代码。在这里,我使用了Listview.builder,因为它将整个数据显示在一个表单元格中。我应该在列表视图的位置使用什么来在不同的单元格中正确显示数据。或者有其他从后端动态显示数据的方式吗?

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));    
});
}},
)),]),

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

最新更新