[英]How do I handle dynamic list of <DataColumn> Widgets to avoid RenderFlex exceptions in Flutter DataTable Widget?
I have a flutter DataTable (in a Container) that is constructed dynamically (values read from API). 我有一个颤动的DataTable(位于容器中),它是动态构造的(从API读取的值)。
Specifically, when it pulls in the columns it throws a RenderFlex exception. 具体来说,当它拉入列时,将引发RenderFlex异常。 The same values used statically pose no problem. 静态使用的相同值没有问题。
Widget bodyData() => DataTable(
columns: colWidgets, // set in setState() function
rows: rowWidgets // set in setState() function ,
);
...
colWidgets = ListofValues.map((value){
return new DataColumn(
label: Text(value)
);
}).toList();
What is the best way to prepare the DataTable for these values via something like Padding or SingleScrollView? 通过Padding或SingleScrollView等为这些值准备DataTable的最佳方法是什么?
I was able to solve this by moving the DataColumn widgets into a FittedBox widget within a Column widget. 通过将DataColumn小部件移动到Column小部件内的FittedBox小部件中,我能够解决此问题。 The key thing is that the parent/ancestor must have a flex property which the Column provides. 关键是父/祖先必须具有Column提供的flex属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.