如何将最后 5 张图像放入下一行的行中?
How do I put the last 5 images into row of the next line?
将最后 5 个 objects 堆叠到下一行的行中
@覆盖
小部件构建(BuildContext 上下文){
return容器(
身高:10,
child: ListView(scrollDirection: Axis.horizontal, children: [
排(
child仁:[
类别卡片(
(Image.asset(
'assets/icons/categoori.png',
身高:70,
宽度:60,
)),
'所有\n类别'),
类别卡片(
(Image.asset(
'assets/icons/Electronics.png',
身高:70,
宽度:60,
)),
'Electronics \n Devices'),
类别卡片(
(Image.asset(
'assets/icons/Mens.JPG',
身高:70,
宽度:60,
)),
"男装\n时尚"),
类别卡片(
(Image.asset(
'assets/icons/womens.JPG',
身高:70,
宽度:60,
)),
" 女装\n 时尚"),
类别卡片(
(Image.asset(
'assets/icons/watch.JPG',
身高:70,
宽度:60,
)),
'手表和\n配件'),
填充(填充:EdgeInsets.only(左:0)),
类别卡片(
(Image.asset(
'assets/icons/abc.JPG',
身高:70,
宽度:60,
)),
'家庭和\n生活方式'),
类别卡片(
(Image.asset(
'assets/icons/health.JPG',
身高:70,
宽度:60,
)),
'健康与\n美容'),
类别卡片(
(Image.asset(
'assets/icons/books.JPG',
身高:70,
宽度:60,
)),
'书籍和\n音乐'),
类别卡片(
(Image.asset(
'assets/icons/gifts.JPG',
身高:70,
宽度:60,
)),
' 礼物 & \n 蛋糕'),
类别卡片(
(Image.asset(
'assets/icons/groceries.JPG',
身高:70,
宽度:60,
)),
'杂货和\n 用品'),
],
),
]),
);
}
}
您可以将项目放在 GridView
中,特别是 GridView.count
以指定每行的项目数:
GridView.count(
crossAxisCount: 5,
children: [
...
],
),
将最后 5 个 objects 堆叠到下一行的行中
@覆盖 小部件构建(BuildContext 上下文){ return容器( 身高:10, child: ListView(scrollDirection: Axis.horizontal, children: [ 排( child仁:[ 类别卡片( (Image.asset( 'assets/icons/categoori.png', 身高:70, 宽度:60, )), '所有\n类别'), 类别卡片( (Image.asset( 'assets/icons/Electronics.png', 身高:70, 宽度:60, )), 'Electronics \n Devices'), 类别卡片( (Image.asset( 'assets/icons/Mens.JPG', 身高:70, 宽度:60, )), "男装\n时尚"), 类别卡片( (Image.asset( 'assets/icons/womens.JPG', 身高:70, 宽度:60, )), " 女装\n 时尚"), 类别卡片( (Image.asset( 'assets/icons/watch.JPG', 身高:70, 宽度:60, )), '手表和\n配件'), 填充(填充:EdgeInsets.only(左:0)), 类别卡片( (Image.asset( 'assets/icons/abc.JPG', 身高:70, 宽度:60, )), '家庭和\n生活方式'), 类别卡片( (Image.asset( 'assets/icons/health.JPG', 身高:70, 宽度:60, )), '健康与\n美容'), 类别卡片( (Image.asset( 'assets/icons/books.JPG', 身高:70, 宽度:60, )), '书籍和\n音乐'), 类别卡片( (Image.asset( 'assets/icons/gifts.JPG', 身高:70, 宽度:60, )), ' 礼物 & \n 蛋糕'), 类别卡片( (Image.asset( 'assets/icons/groceries.JPG', 身高:70, 宽度:60, )), '杂货和\n 用品'), ], ), ]), ); } }
您可以将项目放在 GridView
中,特别是 GridView.count
以指定每行的项目数:
GridView.count(
crossAxisCount: 5,
children: [
...
],
),