Flutter onTap method for Containers

后端 未结 5 915
粉色の甜心
粉色の甜心 2021-02-03 17:56

Been developing a flutter app and dynamicly building some containers from some Firebase data. I wanted to know if there is a way to get a onTap method for containers (or any wi

5条回答
  •  野性不改
    2021-02-03 18:28

    wrapping the container inside an Inkwell() Widget could solve the problem or even GestureDetector() as

      InkWell(                        
            child: Container(...),                        
            onTap: () {                          
            print("tapped on container");
            },                      
         );
    

    Using the Gesture Detector

    GestureDetector(
      onTap: () { print("Container was tapped"); },
      child: Container(...),
    )
    

提交回复
热议问题