gpt4 book ai didi

flutter - 如何使用底部按钮和图像上的文本构建StaggeredGridView

转载 作者:行者123 更新时间:2023-12-03 03:40:36 25 4
gpt4 key购买 nike

我试图在Flutter中使用图像下方的按钮和图像上的文本创建Flutter中的交错网格 View 。我尝试过但没有成功,请帮助我

我将此库用于交错网格 View => flutter_staggered_grid_view

我试过了.....

  StaggeredGridView.countBuilder(
padding: const EdgeInsets.only(
left: 8.0, top: 8.0, right: 8.0, bottom: 8.0),
crossAxisCount: 4,
itemCount: givingList.length,
itemBuilder: (context, j) {
String imgPath = givingList[j]["images"]["post_image1"];
return new Material(
elevation: 8.0,
borderRadius: new BorderRadius.all(new Radius.circular(8.0)),
child: ClipRRect(

borderRadius: new BorderRadius.circular(8.0),
child: Column(
children: <Widget>[
FadeInImage(
placeholder: new AssetImage(UIData.loading),
image: NetworkImage(imgPath),
fit: BoxFit.cover,
),
RaisedGradientButton(
child: Text(
'UPDATE',
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
gradient: LinearGradient(
colors: <Color>[
Color.fromARGB(255, 17, 153, 142),
Color.fromARGB(255, 56, 239, 125)
],
),
onPressed: () {
// updateListing(); //signUpRoute //signUpProfileRoute
}),
],
)

));
},
staggeredTileBuilder: (j) =>
new StaggeredTile.count(2, j.isEven ? 2 : 3),
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
);

我想要这个=> https://ibb.co/VqkFGd6
但是我得到了这个=> https://ibb.co/cJPK9S0

最佳答案

这对我有用

StaggeredGridView.countBuilder(
padding:
const EdgeInsets.only(left: 8.0, top: 8.0, right: 8.0, bottom: 8.0),
crossAxisCount: 4,
itemCount: givingList.length,
itemBuilder: (context, j) {
String imgPath = givingList[j]["images"]["post_image1"];
String title = givingList[j]["title"];
String postID = givingList[j]["key"];
return new Material(
elevation: 8.0,
borderRadius: new BorderRadius.all(new Radius.circular(8.0)),
child: ClipRRect(
borderRadius: new BorderRadius.circular(8.0),
child: Stack(
children: <Widget>[
FadeInImage(
placeholder: new AssetImage(UIData.loading),
image: NetworkImage(imgPath),
fit: BoxFit.cover,
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
height: 60,
child: RaisedGradientButton(
child: Text(
'Make as Given Away',
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
gradient: LinearGradient(
colors: <Color>[
Color.fromARGB(255, 17, 153, 142),
Color.fromARGB(255, 56, 239, 125)
],
),
onPressed: () {
removePost(j, postID);

// updateListing(); //signUpRoute //signUpProfileRoute
}),
)),
Positioned(
bottom: 40,
left: 10,
right: 10,
child: Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontFamily: 'Roboto',
fontWeight: FontWeight.bold,
),
))
],
)),
);
},
staggeredTileBuilder: (j) =>
new StaggeredTile.fit(2),
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
);

关于flutter - 如何使用底部按钮和图像上的文本构建StaggeredGridView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56558592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com