【问题标题】:How to detect tap (or any other gesture event) on Positioned widget on another widget in CustomScrollView?如何在 CustomScrollView 中的另一个小部件上检测定位小部件上的点击(或任何其他手势事件)?
【发布时间】:2021-04-25 10:44:45
【问题描述】:

这是一个小部件树:

CustomScrollView(Clip.none)
  SliverList
    Column
      HourItem
        SizedBox
          Stack
            Positioned(top: 30)

结果是:

我可以处理蓝色箭头指向的点击区域,而不能处理红色箭头。

如果是 web,我会使用 z-index 属性,但如何在 Flutter 中做同样的事情?

【问题讨论】:

    标签: flutter flutter-layout overflow z-index customscrollview


    【解决方案1】:

    使用GestureDetector

    Positioned(top: 30,child: GestureDetector(
                          child:  SomeWidget(),
                          onTap: () {
                            // some action 
                          },
                        ),),
    

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 2021-12-01
      • 2021-03-17
      • 2020-05-26
      • 2011-08-10
      • 2023-03-23
      • 2011-07-17
      • 2023-03-11
      • 2019-07-05
      相关资源
      最近更新 更多