flutter-按下容器?
问题内容:
我有这个容器:
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
呢?
问题答案:
我猜你可以GestureDetector
像这样使用小部件:
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"),
]
),
)
);