加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

user-interface – Flutter – 容器onPressed?

发布时间:2020-12-14 14:58:32 所属栏目:百科 来源:网络整理
导读:我有这个容器: 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方法(例如,可以使用I
我有这个容器:

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方法(例如,可以使用IconButtons来完成).如何使用容器实现此行为?

提前致谢

解决方法

我想你可以像这样使用GestureDetector小部件:

new GestureDetector(
        onTap: (){
          print("Container clicked");
        },child: new Container(
          width: 500.0,]
          ),)
    );

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读