美文网首页flutter
Flutter之IgnorePointer组件

Flutter之IgnorePointer组件

作者: 习惯了_就好 | 来源:发表于2019-07-16 15:35 被阅读1次
/**
 * 忽略触摸事件,
 * IgnorePointer和AbsorbPointer,这两个Widget都能阻止子树接收指针事件,不同的是AbsorbPointer本身是可以接收指针事件的(但其子树不行),而IgnorePointer本身就不可以接收指针事件
 * const IgnorePointer({
    Key key,
    this.ignoring = true,//控制是否忽略
    this.ignoringSemantics,
    Widget child,
    })
 */
body: Center(
            child: Listener(
              child: IgnorePointer(
                  child: Listener(
                    child: Container(
                      width: 200,
                      height: 200,
                      color: Colors.orange,
                    ),
                    onPointerDown: (event) =>
                        debugPrint("内层点击事件"),
                    onPointerMove: (event) =>
                        debugPrint("onPointerMove:  " + event.delta.toString()),
                    onPointerUp: (event) =>
                        debugPrint("onPointerUp:  " + event.toString()),
                  )
              ),
              onPointerDown: (event) => debugPrint("外层点击事件"),
            ),
          )

//按下什么都不会打印-------

相关文章

网友评论

    本文标题:Flutter之IgnorePointer组件

    本文链接:https://www.haomeiwen.com/subject/kvrtlctx.html