[英]Need help figuring out how to limit number of columns in a row of grid view
您好,我正在使用名为responsive_framework的 package 并且我正在使用ResponsiveGridView ,我无法弄清楚如何限制列数。 我尝试将maxRowCount
设置为 2,但如果我这样做,它会添加额外的项目,即 null,因为我只想要 4,但它会像这样在每行添加 10、5。
我正在寻找的是每行 2 个项目。
这是我使用的代码
ResponsiveGridView.builder(
shrinkWrap: true,
gridDelegate: ResponsiveGridDelegate(
crossAxisExtent: 300,
childAspectRatio: 3 / 4,
crossAxisSpacing: 50,
),
itemCount: people.length,
itemBuilder: (BuildContext bc, index) {
return Card(
child: ResponsiveRowColumn(
rowColumn: false,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
child: Image.network(
"https://thumbs.dreamstime.com/b/smartphone-hand-businessman-holding-mobile-phone-cell-arm-template-app-presentation-flat-vector-internet-application-blank-155035117.jpg",
scale: 1,
),
),
ResponsiveRowColumnItem(
child: Text(people[index].name),
),
],
),
);
}),
没有办法限制对象的数量,但是您可以做的是将 gridview 放入容器中并限制给出我想要的结果的大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.