【发布时间】:2022-01-03 03:40:01
【问题描述】:
我有一个带有动态项目数的 gridView(连续 3 个项目)。我希望gridView项目应该在底部意味着如果有3个项目然后在屏幕底部一行,如果有6个项目然后在底部两行。因此,顶部的动态填充取决于项目数和屏幕大小。我的代码结构如下
class className extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: [
ImageFiltered(
//code here
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.black38,
),
GridView.builder(
primary: false,
reverse: false,
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 30,
),
itemBuilder: (context, index) {
return InkWell(
onTap: () {
//code
},
child: CustomWidget(
title: toolkitStore.getLabel(toolKit),
icon: ImageIcon(
AssetImage(
'assets/images/abcd.png'),
size: 48,
color: kWhiteColor,
),
),
);
},
itemCount: getCount().length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
),
],
),
),
);
}
}
现在我有了这个
但我想要这个
提前致谢。
【问题讨论】:
标签: flutter gridview alignment