我正在尝试将Row中的项(容器)限制为8个,如果有更多的项,则应该包装它们。我有一个容器列表,但由于listView滚动,我不能使用listView作为Wrap的子项。有没有办法修复这个布局?
我曾尝试使用循环,但当它第一次点击return时,它走出了循环。
Expanded(
flex: 4,
child: Wrap(
direction: Axis.horizontal,
spacing: 0.5,
runSpacing: 0.5,
crossAxisAlignment: WrapCrossAlignment.center,
children: <Widget>[
// I want something that works like following line
//Container(child: kids1)
//currently I can get results with following code
kids1[1],
kids1[2],
kids1[3], kids1[4], kids1[5], kids1[6],
kids1[7], kids1[8], kids1[9], kids1[10],
kids1[11]
],
),
),
kids是一个容器列表
发布于 2019-06-05 03:22:12
为什么不在build函数返回之前创建子函数的列表:
@override
Widget build(BuildContext context) {
List<Widget> children = List.generate(myContainerList.length, (e) => myContainerList[e]);
return Wrap(
children: children,
);
}
https://stackoverflow.com/questions/56449105
复制相似问题