扑扑中IgnorePointer小部件的用例是什么?

问题描述 投票:0回答:1

我已经看到IgnorePointer窗口小部件扑朔迷离,但是用例似乎很少见。有人可以用更多的用例和示例来详细说明吗?

flutter flutter-layout
1个回答
0
投票

例如,如果要创建自定义窗口小部件,如下图所示

Stack(
   children: <Widget>[
      GestureDetector(
         child: Container(
            color: Colors.amber,
            width: 100,
            height: 100
         ),
         onTap: () {
            print('clicked');
         },
      ),
      Container(
         color: Colors.green,
         width: 50,
         height: 50,
      ),
   ],
),

看起来像:

Example Image

在此小部件中,您已将拍打功能添加到琥珀色容器中。但是,如果用户点击绿色容器,则您的琥珀色容器将不会受到任何触摸]

© www.soinside.com 2019 - 2024. All rights reserved.