Flutter: Is it possible to click through a PageView?

前端 未结 2 1245
天涯浪人
天涯浪人 2020-12-20 20:17

Trying to make widgets behind a PageView clickable by wrapping it around a GestureDetector but it doesn\'t work. Is there another way I can do this?

new Gest         


        
相关标签:
2条回答
  • 2020-12-20 20:25

    Try using the IgnorePointer class: https://docs.flutter.io/flutter/widgets/IgnorePointer-class.html

    A widget that is invisible during hit testing.

    0 讨论(0)
  • 2020-12-20 20:44

    I just got it to work like this!

    First, wrap the individual children in GestureDetector that you want to interact with.

    Second, set the hit test behavior to translucent.

    PageView(
     ...
     children: [
       FirstChild(), 
       SecondChild(),
       //Child that you want gestures passed down to                  
       GestureDetector(
          behavior: HitTestBehavior.translucent,
          child: GesturedThirdChild(),
       ),
      ]
    
    0 讨论(0)
提交回复
热议问题