Flutter:Inkwell不适用于Card

我正在尝试在卡窗口小部件上实现包装并对其进行包装,但是它根本不起作用。我将Tap保留为null,因为此类使用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,

);

}

回答:

说明:

“发生的事情是Material规范说飞溅实际上是在Material上的墨水。因此,当我们飞溅时,我们所做的就是从字面上使Material部件执行飞溅。如果您在Material之上有东西,我们溅在它下面,你看不到它。”

解决方法:

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 的全部内容, 来源链接: utcz.com/qa/420410.html

回到顶部