颤振-按下容器? [英] Flutter - Container onPressed?
本文介绍了颤振-按下容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个容器:
new Container(
width: 500.0,
padding: new EdgeInsets.fromLTRB(20.0, 40.0, 20.0, 40.0),
color: Colors.green,
child: new Column(
children: [
new Text("Ableitungen"),
]
),
),
当用户点击 Container
,我希望触发 onPressed()
方法(就像可以使用 IconButton
)。我如何使用 Container
实现此行为?
When the user clicks on the Container
, I want an onPressed()
method to be fired (like it can be done with IconButton
for example). How can I achieve this behaviour with Container
?
推荐答案
我猜你可以像这样使用 GestureDetector
小部件:
I guess you can use GestureDetector
widget like this:
new GestureDetector(
onTap: (){
print("Container clicked");
},
child: new Container(
width: 500.0,
padding: new EdgeInsets.fromLTRB(20.0, 40.0, 20.0, 40.0),
color: Colors.green,
child: new Column(
children: [
new Text("Ableitungen"),
]
),
)
);
这篇关于颤振-按下容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文