Flutter - Container onPressed?

后端 未结 6 1780
孤街浪徒
孤街浪徒 2021-01-30 20:01

I have this container:

  new Container(
    width: 500.0,
    padding: new EdgeInsets.fromLTRB(20.0, 40.0, 20.0, 40.0),
    color: Colors.green,
    child: new C         


        
6条回答
  •  忘掉有多难
    2021-01-30 20:24

    If you want a simple tap event then you can do it by GestureDetector

    GestureDetector(
        onTap: (){
          print("Container clicked");
        },
        child: new Container(...)          
    );
    

    If you want ripple animation on tap event then use InkWell

    InkWell(
        onTap: (){
          print("Container clicked");
        },
        child: new Container(...)          
    );
    

提交回复
热议问题