还尝试了onPressed()IconButton,而不是print。同样尝试了IgnorePointer,没有任何变化,有趣的事情是onLongPress()正在工作。是否是因为在容器内。此绿色按钮正在讨论。

firebase - InkWell的onTap()不触发-LMLPHP

                              Container(
                                  height: 50,
                                  width:50,
                                  padding: const EdgeInsets.all(15.0),
                                  decoration: BoxDecoration(
                                      color: myGreen, shape: BoxShape.circle),
                                  child: InkWell(
                                    child: Icon(
                                      Icons.send,
                                      color: Colors.white,
                                    ),
                                    onTap:(){
                                      print("sdsdsd");
                                      //sendChatToFirestore();
                                    },
                                    onLongPress: (){
                                      print("long press");
                                    },

                                  ),
                                )

最佳答案

试试这个。无需使用多个小部件创建困惑,您可以使用开箱即用的FAB来执行相同的操作

FloatingActionButton(
        onPressed: () {
          print("sdsdsd");
          //sendChatToFirestore();
        },
        backgroundColor: Colors.green,
        child: Icon(
          Icons.send,
          color: Colors.white,
        ),
      ),

或者,如果您想进一步控制按钮,请使用简单的FlatButton
FlatButton(               //change to RaisedButton to be raised
          onPressed: () {
            print("sdsdsd");
            //sendChatToFirestore();
          },
          onLongPress: () {
            print("long press");
          },
          padding: EdgeInsets.all(16),
          shape: CircleBorder(),
          color: Colors.green,
          child: Icon(
            Icons.send,
            color: Colors.white,
          ),
        ),

如此简单的小部件无需重新发明轮子

输出值

firebase - InkWell的onTap()不触发-LMLPHP

关于firebase - InkWell的onTap()不触发,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61833544/

10-09 10:18