I'm trying to dynamically create tables using Dart and Flutter.
(我正在尝试使用Dart和Flutter动态创建表。)
Something like this The number of table rows will change depending on the the JSON file passed in. (事情是这样的表中的行数将根据传入的JSON文件更改。)
I've read through and done all of the Flutter tutorials I can get my hands on and read through the Documentation on the Table and ListBuilder classes, but none of them quite accomplish what I'm trying to do, because the examples either only dynamically create single ListItems or all the data and/or Widgets are hard-coded.
(我已经阅读并完成了所有Flutter教程,可以动手操作并阅读Table和ListBuilder类上的文档,但是它们都不能完全完成我想做的事情,因为这些示例只是动态地创建单个ListItem或所有数据和/或小部件都经过硬编码。)
I've also tried doing this by doing: Table dynamicTable = new Table();
(我也尝试过这样做: Table dynamicTable = new Table();
)
then dynamically adding children Widgets with (然后动态添加子控件)
dynamicTable.add(TableRow(
children: [
Text("test1"),
Text("test2"),
Text("test3"),
]
));
But I get an error saying "Cannot add to an unmodifiable list".
(但是我收到一个错误消息,说“无法添加到不可修改的列表”。)
Any tips on how to accomplish this would be greatly appreciated.
(任何有关如何完成此操作的技巧将不胜感激。)
ask by kaden_shaihd translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…