gpt4 book ai didi

Flutter:Inkwell 不适用于 Card

转载 作者:IT老高 更新时间:2023-10-28 12:34:56 25 4
gpt4 key购买 nike

我正在尝试在卡片小部件上实现和 inkWell 包装,但它根本不起作用。我将点击保留为空,因为该类需要 3 个参数,我稍后会填充这些参数以生成多张卡片。我看不到阻止 InkWell 产生涟漪的原因,因此我们将不胜感激。

class FeedBackCardsImage extends StatelessWidget {
final String imagePath;
final String cardTitle;
final String cardTag;

FeedBackCardsImage({
this.imagePath,
this.cardTitle,
this.cardTag,
});

@override
Widget build(BuildContext context) {

return InkWell(
child: new Container(
child: new Card(
child: new Padding(
padding: new EdgeInsets.all(15.0),
child: new Column(
children: <Widget>[
new SizedBox(
height: 184.0,
child: new Stack(
children: <Widget>[
new Positioned.fill(
child: new Image.asset(
imagePath,
//package: destination.assetPackage,
fit: BoxFit.contain,
),
),
],
),
),
new Padding(
padding: new EdgeInsets.all(
7.0,
),
child: new Text(
cardTitle,
style: new TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w600,
color: Colors.black87),
),
),
new Padding(
padding: new EdgeInsets.all(
0.0,
),
child: new Text(
cardTag,
style: new TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w400,
color: Colors.black54),
),
),
],
),
),
),
),
onTap: null,

);



}

最佳答案

解释:

"What's going on is that the Material spec says that the splashes are actually ink on the Material. So when we splash, what we do is we literally have the Material widget do the splash. If you have something on top of the Material, we splash under it, and you can't see it."

解决方法:

return Stack(children: <Widget>[
new Card(
child: new Padding(
padding: new EdgeInsets.all(15.0),
child: new Column(
children: <Widget>[
new SizedBox(
height: 184.0,
child: new Stack(
children: <Widget>[
new Positioned.fill(
child: new Image.asset(
imagePath,
//package: destination.assetPackage,
fit: BoxFit.contain,
),
),
],
),
),
new Padding(
padding: new EdgeInsets.all(
7.0,
),
child: new Text(
cardTitle,
style: new TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w600,
color: Colors.black87),
),
),
new Padding(
padding: new EdgeInsets.all(
0.0,
),
child: new Text(
cardTag,
style: new TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w400,
color: Colors.black54),
),
),
],
),
),
),
new Positioned.fill(
child: new Material(
color: Colors.transparent,
child: new InkWell(
onTap: () => null,
)))
]);

关于Flutter:Inkwell 不适用于 Card,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51508438/

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