Flutter- GestureDetector not working with containers in stack

前端 未结 10 823
一生所求
一生所求 2020-12-28 12:14

I have two containers in a stack and both containers have GestureDetector.The OnTap for the first container is working fine but it\'s not working with another container. The

10条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 12:29

    GestureDetector is not working when write code inside its block It will be doesn't work

    GestureDetector(
                      onTap: () {
                        setState(() {
                          _color = Colors.red;
                        });
                      },),
    

    You will write like that it will work

    GestureDetector(
                      onTap: () {
                        changed();
                      },),
    

    method

    void changed() {
    setState(() {
      _color = Colors.red;
    });}
    

提交回复
热议问题