Flutter - Container onPressed?

133

我有这个容器:

  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中实现此行为?

11个回答

-1
InkWell(
    child: Container(/* ... */),
    onTap: () { 
        print("Add your on tap event in this block"); 
    },
);

使用InkWell,因为它会为您提供漂亮的材料涟漪效果。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接