作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在尝试在卡片小部件上实现和 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/
我是一名优秀的程序员,十分优秀!