gpt4 book ai didi

Flutter - 容器 onPressed?

转载 作者:IT老高 更新时间:2023-10-28 13:49:32 40 4
gpt4 key购买 nike

我有这个容器:

  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"),
]
),
)
);

关于Flutter - 容器 onPressed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43692923/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com