Flutter 在定位小部件内使用RaisedButton小部件问题

Flutter 在定位小部件内使用RaisedButton小部件问题,flutter,dart,Flutter,Dart,在定位的小部件中使用RaisedButton时,我遇到了一个问题 问题是,当我在定位的小部件中使用RaisedButton时,当单击RaisedButton子项时,onPressed事件没有触发,但当我单击RaisedButton的另一个空间时,它工作了 请注意,它在正常情况下工作正常,在Positioned小部件中使用RaisedButton时发生 这是我的小部件: Positioned( child: Center( child: SizedBox(

定位的
小部件中使用
RaisedButton
时,我遇到了一个问题

问题是,当我在
定位的
小部件中使用
RaisedButton
时,当单击
RaisedButton
子项时,
onPressed
事件没有触发,但当我单击
RaisedButton
的另一个空间时,它工作了

请注意,它在正常情况下工作正常,在
Positioned
小部件中使用
RaisedButton
时发生

这是我的小部件:

Positioned(
    child: Center(
        child: SizedBox(
            width: 80,
            height: 65,
            child: RaisedButton(
                padding: EdgeInsets.all(0),
                shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
                color: Colors.green,
                child: Icon(Icons.message, size: 50, color: Colors.white,), 
                // When I clicked on this icon, onPressed didn't triggered. but when I click on another space of button it triggered.
                onPressed: () {
                    print('Hello world from onPressed');
                },
            ),
        ),
    ),
    top: -30,
    left: 0,
    right: 0,
)
你对解决这个问题有什么想法

简单的回答是:

颤振不会为重叠堆栈边界的项触发推送事件(这是在将top设置为-30时所做的)

这背后的原因可以在这里找到:


一个可能的解决方案是将所有其他项目移动到30.0以下,以便将按钮放置在堆栈中。

此问题的解决方案是将堆栈包装在手势检测器中,并在按下手势检测器的ontap属性中的提升按钮时添加要添加的内容。当我将
top
属性更改为
0
时,它起作用了。我认为这个问题发生在使用否定位置时。