本文介绍了Flutter:Inkwell不适用于Card的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在卡片小部件上实现包装并对其进行包装,但是它根本不起作用.我将Tap保留为null,因为此类使用3个参数,稍后将其填充以生成多个卡.我看不到发生了什么,这阻止了InkWell的崩溃,因此,我们将不胜感激.
I am trying to implement and inkWell wrap on a card widget, but it does not work at all. I am leaving on tap as null because this class takes 3 arguments that I populate later on to generate multiple cards.I cannot see what is going on that is preventing InkWell from rippling, so any help would be appreciated.
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,
);
}
推荐答案
说明:
解决方法:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!