我有json:
{ “名字”:“测试”, “groupsCount”:5, “团体”:[ { “名字”:“威廉库珀”, “1号, “linesCount”:2, “线”:[ …
您需要更改_buildRow()和_buildRowList()方法:
Widget _buildRow(Groups parkingGroup, BuildContext context) { return Container( padding: const EdgeInsets.all(16.0), child: Column( // As you expect multiple lines you need a column not a row children: _buildRowList(parkingGroup), ), ); } List<Widget> _buildRowList(Groups parkingGroup) { List<Widget> lines = []; // this will hold Rows according to available lines for (var line in parkingGroup.lines) { List<Widget> placesForLine = [] // this will hold the places for each line for (var placeLine in line.places) { placesForLine.add(_buildPlace(placeLine)); } lines.add(Row(children: placesForLine)); } return lines; }