问题描述
这是我的代码。在这里,我使用了Listview.builder,因为整个数据都显示在1个表单元格中。我应该在列表视图位置使用什么来正确显示不同单元格中的数据。 还是通过其他方式从后端动态显示数据?
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