4

There is a GestureDetector above the WebView.

when I touch the GestureDetector, the WebView is also response touch event.

Widget build(BuildContext context) {
  return Scaffold(
    body: Stack(
      children: <Widget>[
        WebView(
          initialUrl: url,
          javascriptMode: JavascriptMode.unrestricted
        ),
        GestureDetector(
          child:Image.asset('.....'),
          onTap:(){
            //do something
          }
        )
      ],
    ),
  );
}

How Can I stop WebView's touch response when I tap the GestureDetector?

Andrii Turkovskyi
  • 27,554
  • 16
  • 95
  • 105

1 Answers1

6

I thhink this is what you need. AbsorbPointer is absorbing all the touches and doesn't allow WebView to get them.

Stack(
  children: <Widget>[
    AbsorbPointer(
      child: WebView(
        initialUrl: url,
        javascriptMode: JavascriptMode.unrestricted
      ),
    ),
    GestureDetector(
      child:Image.asset('.....'),
      onTap:(){
        //do something
      }
    )
  ],
);
Andrii Turkovskyi
  • 27,554
  • 16
  • 95
  • 105