8000 webview response to gesture from the widget above it · Issue #58659 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

webview response to gesture from the widget above it #58659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hxjhnct opened this issue Jun 4, 2020 · 33 comments
Open

webview response to gesture from the widget above it #58659

hxjhnct opened this issue Jun 4, 2020 · 33 comments
Labels
f: gestures flutter/packages/flutter/gestures repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on p: webview The WebView plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@hxjhnct
Copy link
hxjhnct commented Jun 4, 2020

webView_flutter for iOS ,When loading the map URL, stack will overlay a gesturedetector event, which will penetrate the map page。。Loading other https web will not appear

  return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Stack(
        children: <Widget>[
          WebView(
            javascriptMode: JavascriptMode.unrestricted,
            javascriptChannels: <JavascriptChannel>[].toSet(),
            onWebViewCreated: (WebViewController controller) {
              ///url: https://www.google.com
              _webViewController.loadUrl('https://gaode.com/');
            },
            onPageFinished: (String value) {},
          ),
          Positioned(
            left: 100.0,
            top: 100.0,
            child: GestureDetector(
              onTap: () {
                print('click red...');
              },
              child: Container(
                width: 100.0,
                height: 100.0,
                color: Colors.red,
              ),
            ),
          )
        ],
      ),
    );
@VladyslavBondarenko
Copy link
VladyslavBondarenko commented Jun 4, 2020

On iOS gesture is propagated to the WebView until you touch the WebView - then it stops.
Doesn't reproduce on android.

webview_flutter: ^0.3.22+1

flutter doctor -v
[✓] Flutter (Channel dev, 1.19.0-3.0.pre, on Mac OS X 10.15.5 19F101, locale en-GB)
    • Flutter version 1.19.0-3.0.pre at /Users/nevercode/dev/flutter_dev
    • Framework revision 6135091de9 (3 days ago), 2020-06-01 17:17:03 -0700
    • Engine revision e39301f23f
    • Dart version 2.9.0 (build 2.9.0-11.0.dev 6489a0c68d)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/nevercode/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.11.0

[✓] Connected device (5 available)
    • Android SDK built for x86 • emulator-5554                            • android-x86    • Android 10 (API 29) (emulator)
    • Nevercode’s iPhone        • b668e524315069f3db3661ac11ff1f66afafebdb • ios            • iOS 13.5
    • macOS                     • macOS                                    • darwin-x64     • Mac OS X 10.15.5 19F101
    • Web Server                • web-server                               • web-javascript • Flutter Tools
    • Chrome                    • chrome                                   • web-javascript • Google Chrome 83.0.4103.61

• No issues found!

@VladyslavBondarenko VladyslavBondarenko added f: gestures flutter/packages/flutter/gestures repository. found in release: 1.19 Found to occur in 1.19 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-ios iOS applications specifically p: webview The WebView plugin plugin labels Jun 4, 2020
@VladyslavBondarenko VladyslavBondarenko changed the title webView_flutter for iOS ,When loading the map URL, stack will overlay a gesturedetector event, which will penetrate the map page。。Loading other https web will not appear [webView_flutter][iOS] positioned widget in stack propagates gestures to non-positioned in stack webview with mapuredetector event, which will penetrate the map page。。Loading other https web will not appear Jun 4, 2020
@VladyslavBondarenko VladyslavBondarenko changed the title [webView_flutter][iOS] positioned widget in stack propagates gestures to non-positioned in stack webview with mapuredetector event, which will penetrate the map page。。Loading other https web will not appear [webView_flutter][iOS] positioned widget in stack propagates gestures to non-positioned in stack webview with map Jun 4, 2020
@VladyslavBondarenko VladyslavBondarenko added the P2 Important issues not at the top of the work list label Jun 4, 2020
@thepday12

This comment was marked as duplicate.

@pedromassangocode
Copy link

Reproduced based on #73926

I was able to reproduce the issue!

gif

code sample
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('widget.title'),
        ),
        body: Container(
          color: Colors.grey,
          child: Stack(
            children: [
              Positioned(
                  left: 100,
                  top: 20,
                  width: 100,
                  height: 100,
                  child: GestureDetector(
                    onTap: (){
                      print('red click');
                    },
                    child: Container(
                      color: Colors.red,
                    ),
                  )
              ),
              Positioned(
                  left: 100,
                  top: 40,
                  width: 100,
                  height: 100,
                  child: GestureDetector(
                    onTap: (){
                      print('blue click');
                    },
                    child: Container(
                      color: Colors.blue,
                    ),
                  )
              ),
              Positioned(
                  left: 0,
                  top: 150,
                  width: 400,
                  height: 400,
                  child:Container(
                    child: WebView(
                      onWebViewCreated: (WebViewController webViewController){
                      },
                      initialUrl: 'https://devpost.com/software/built-with/fabric-js',
                      javascriptMode: JavascriptMode.unrestricted,
                      onPageStarted: (String info){
                      },
                      onPageFinished: (String info){

                      },
                      onWebResourceError: (error){

                      },
                      gestureNavigationEnabled: true,
                      // javascriptChannels: [_toastJsChannel(viewService.context,state,dispatch)].toSet(),
                    ),
                  )
              ),
              Positioned(
                left: 20,
                top: 270,
                width: 200,
                height: 200,
                child: GestureDetector(
                  onTap: (){
                    print('yellow click');
                  },
                  child: Container(
                    color: Colors.yellow,
                  ),
                ),
              )
            ],
          ),
        )
      // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
flutter doctor -v
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H114 darwin-x64, locale en)
    • Flutter version 1.22.5 at /Users/pedromassango/dev/SDKs/flutter_stable
    • Framework revision 7891006299 (6 weeks ago), 2020-12-10 11:54:40 -0800
    • Engine revision ae90085a84
    • Dart version 2.10.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/pedromassango/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.9.3

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2020.3.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin installed
    • Dart plugin version 203.6912

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.1

[✓] Connected device (1 available)
    • iPhone 12 Pro Max (mobile) • ECCF5C4A-8BEC-411D-B23E-85A836C3847E • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-1 (simulator)

! Doctor found issues in 1 category.
Process finished with exit code 0

@pedromassangocode pedromassangocode added found in release: 1.12 Found to occur in 1.12 found in release: 1.22 Found to occur in 1.22 and removed found in release: 1.19 Found to occur in 1.19 found in release: 1.12 Found to occur in 1.12 labels Jan 22, 2021
@pedromassangocode pedromassangocode changed the title [webView_flutter][iOS] positioned widget in stack propagates gestures to non-positioned in stack webview with map webview response to gesture from the widget above it Jan 22, 2021
@beydeng
Copy link
beydeng commented Jan 27, 2021

Is there any way to resolve this situation?

@jamesdixon
Copy link

Hello! Also running into this. Has anyone found a workaround?

@yiv
Copy link
yiv commented Apr 28, 2021

Me too, Has anyone found a workaround?

@jamesdixon
Copy link

@yiv no true workaround. I ended up just having to push a new route on top of the webview to display the interface I needed.

@danagbemava-nc
Copy link
Member

Reproducible on master 2.5.0-6.0.pre.46 and stable 2.2.3 with webview_flutter: ^2.0.12.

flutter doctor -v
[✓] Flutter (Channel master, 2.5.0-6.0.pre.46, on macOS 11.5.1 20G80 darwin-arm,
    locale en-GH)
    • Flutter version 2.5.0-6.0.pre.46 at /Users/nexus/dev/sdks/flutters
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41ff30c871 (16 minutes ago), 2021-08-10 23:03:48 -0700
    • Engine revision 4fef55db10
    • Dart version 2.14.0 (build 2.14.0-385.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.59.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.25.0

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        •
      android-arm64  • Android 12 (API 31) (emulator)
    • iPhone 12 (mobile)          • F2592D43-5FE3-46BB-8A2B-A38BA468DCE9 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web)                • chrome                               •
      web-javascript • Google Chrome 92.0.4515.131

• No issues found!
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-arm, locale
    en-GH)
    • Flutter version 2.2.3 at /Users/nexus/dev/sdks/flutter
    • Framework revision f4abaa0735 (6 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.59.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.25.0

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        •
      android-arm64  • Android 12 (API 31) (emulator)
    • iPhone 12 (mobile)          • F2592D43-5FE3-46BB-8A2B-A38BA468DCE9 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web)                • chrome                               •
      web-javascript • Google Chrome 92.0.4515.131

• No issues found!

Simulator Screen Recording - iPhone 12 - 2021-08-11 at 10.28.05.mp4.zip

code sample
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('widget.title'),
        ),
        body: Container(
          color: Colors.grey,
          child: Stack(
            children: [
              Positioned(
                  left: 100,
                  top: 20,
                  width: 100,
                  height: 100,
                  child: GestureDetector(
                    onTap: () {
                      print('red click');
                    },
                    child: Container(
                      color: Colors.red,
                    ),
                  )),
              Positioned(
                  left: 100,
                  top: 40,
                  width: 100,
                  height: 100,
                  child: GestureDetector(
                    onTap: () {
                      print('blue click');
                    },
                    child: Container(
                      color: Colors.blue,
                    ),
                  )),
              Positioned(
                  left: 0,
                  top: 150,
                  width: 400,
                  height: 400,
                  child: Container(
                    child: WebView(
                      onWebViewCreated:
                          (WebViewController webViewController) {},
                      initialUrl:
                          'https://devpost.com/software/built-with/fabric-js',
                      javascriptMode: JavascriptMode.unrestricted,
                      onPageStarted: (String info) {},
                      onPageFinished: (String info) {},
                      onWebResourceError: (error) {},
                      gestureNavigationEnabled: true,
                      // javascriptChannels: [_toastJsChannel(viewService.context,state,dispatch)].toSet(),
                    ),
                  )),
              Positioned(
                left: 20,
                top: 270,
                width: 200,
                height: 200,
                child: GestureDetector(
                  onTap: () {
                    print('yellow click');
                  },
                  child: Container(
                    color: Colors.yellow,
                  ),
                ),
              )
            ],
          ),
        )
        // This trailing comma makes auto-formatting nicer for build methods.
        );
  }
}

@danagbemava-nc danagbemava-nc added found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 and removed found in release: 1.22 Found to occur in 1.22 labels Aug 11, 2021
@Justus-M
Copy link

try using inappwebview plugin it might work

No, it doesn't

@anandzhang
Copy link

I tried again to use 😘 visibility_detector to control the touchable area of the native ads implemented with webview, not a good solution but it solved the problem I was having for now.

I use the onVisibilityChanged to help me update the touchable area of my native ads. When the user touch point is not on the visible area of the ad, the touch event is intercepted.

visibility_detector#known-limitations. I use another method to solve the problem of overlay not being detected, but it is not good. idea.

Here is a snippet of my code:

gromore_feed_view.dart
/// 信息流广告组件
class GromoreFeedView extends StatefulWidget {
  final Map<String, String> creationParams;

  /// 回调
  final GromoreFeedCallback callback;

  const GromoreFeedView({
    Key? key,
    required this.creationParams,
    required this.callback,
  }) : super(key: key);

  @override
  State<GromoreFeedView> createState() => _GromoreFeedViewState();
}

class _GromoreFeedViewState extends State<GromoreFeedView> {
  final UniqueKey _detectorKey = UniqueKey();
  MethodChannel? _methodChannel;

  @override
  void initState() {
    VisibilityDetectorController.instance.updateInterval =
        const Duration(milliseconds: 100);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    String viewType = FlutterGromoreConstants.feedViewTypeId;

    return Platform.isAndroid
        // Android PlatformViewLink is hidden
        ? const SizedBox.shrink()
        : VisibilityDetector(
            key: _detectorKey,
            child: UiKitView(
              viewType: viewType,
              creationParams: widget.creationParams,
              creationParamsCodec: const StandardMessageCodec(),
              onPlatformViewCreated: (id) {
                final String channelName = "$viewType/$id";
                _methodChannel = MethodChannel(channelName);
                // 注册事件回调
                GromoreMethodChannelHandler<GromoreFeedCallback>.register(
                    channelName, widget.callback);
              },
            ),
            onVisibilityChanged: (VisibilityInfo visibilityInfo) {
              if (!mounted) return;
              // 被遮盖了
              final bool isCovered = visibilityInfo.visibleFraction != 1.0;
              final Offset offset = (context.findRenderObject() as RenderBox)
                  .localToGlobal(Offset.zero);
              _methodChannel?.invokeMethod('updateVisibleBounds', {
                'isCovered': isCovered,
                'x': offset.dx + visibilityInfo.visibleBounds.left,
                'y': offset.dy + visibilityInfo.visibleBounds.top,
                'width': visibilityInfo.visibleBounds.width,
                'height': visibilityInfo.visibleBounds.height,
              });
            },
          );
  }
}
FlutterGromoreIntercptPenetrateView.swift
//
//  FlutterGromoreIntercptPenetrateView.swift
//  flutter_gromore
//
//  Created by Anand on 2022/6/13.
//

/// 用于拦截点击穿透
class FlutterGromoreIntercptPenetrateView: UIView {
  /// 存在穿透问题?
  var isPermeable: Bool = false
  /// 广告是否被覆盖
  var isCovered: Bool = false
  /// 广告的可见区域
  var visibleBounds: CGRect = CGRect.zero
  
  init(frame: CGRect, methodChannel: FlutterMethodChannel) {
    super.init(frame: frame)
    methodChannel.setMethodCallHandler(handle(_:result:))
  }
  
  required init?(coder: NSCoder) {
    super.init(coder: coder)
  }
  
  func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
    switch call.method {
    case "updateVisibleBounds":
      let args: [String: Any] = call.arguments as! [String: Any]
      isCovered = args["isCovered"] as! Bool
      visibleBounds = CGRect(x: args["x"] as! Double, y: args["y"] as! Double, width: args["width"] as! Double, height: args["height"] as! Double)
      result(true)
    default:
      result(FlutterMethodNotImplemented)
    }
  }
  
  override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
    if isPermeable {
      // 在窗口的点击位置
      let windowPoint: CGPoint = convert(point, to: Utils.getVC().view)
      // 被覆盖时 -> 点击位置不在可见区域
      if isCovered, !visibleBounds.contains(windowPoint) {
        return false
      }
    }
    return true
  }
}

@weibinhwb
Copy link

I tried again to use 😘 visibility_detector to control the touchable area of the native ads implemented with webview, not a good solution but it solved the problem I was having for now.

I use the onVisibilityChanged to help me update the touchable area of my native ads. When the user touch point is not on the visible area of the ad, the touch event is intercepted.

visibility_detector#known-limitations. I use another method to solve the problem of overlay not being detected, but it is not good. idea.

Here is a snippet of my code:

gromore_feed_view.dart
FlutterGromoreIntercptPenetrateView.swift

Hello, I had read your blog -- https://anandzhang.com/posts/frontend/22. But I still don't know why the PlatformView penetrate happen in some special case? such as yours, and this issue. I create a demo that a FlutterOverlayView over a PlatformView, it works well.

@hc2088
Copy link
hc2088 commented Oct 20, 2022

遇到同样的问题
Page设置 opaque:false,跳转新页面,新页面窗口比下面的小,下面是上个page,是一个WebView Widget,也是能穿透,怎么去掉事件穿透

@c-odom
Copy link
c-odom commented Jan 10, 2023

Hi there
Is there any update or workaround for this issue?

I used PlatformView to render Native Ad which was implemented using Google Mobile Ad SDK. When I tap on the widget above the ad, it's also received the touch gesture . This happens on iOS, Android doesn't seem to have this problem.
I tried to use the visibility_detector's onVisibilityChanged visibleBounds to control the touchable area of the ad, but it wasn't what I expected.

Similar issue also happen in googleads-mobile-flutter package: googleads/googleads-mobile-flutter#390

If anyone knows or has the solution to this issue, please kindly help 🙇‍♂️

flutter doctor -v

[✓] Flutter (Channel stable, 3.3.9, on macOS 12.6.2 21G317 darwin-x64, locale en)
    • Flutter version 3.3.9 on channel stable at /Users/jayzwalker/fvm/versions/3.3.9
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (7 weeks ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/jayzwalker/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.56.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.6.2 21G317 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 97.0.4692.99

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@itsthetaste
Copy link

I'm also having this issue.

I tried putting a ModalBarrier above my WebViewWidget and some js events still triggered. Links were not clickable.

@taolin2107

This comment was marked as off-topic.

1 similar comment
@gagaisGod

This comment was marked as off-topic.

@krishnaprasadgandrath-nooor

Using pointer interceptor worked for me.

@jianpuzhai

This comment was marked as duplicate.

@kcisoul
Copy link
kcisoul commented Apr 10, 2023

I spent couple of days to solve this problem.
I think I tried every workaround here and stackOverflow.
Finally I got the answer myself. (it's just simple workaround.)
When you need to draw widgets over WebView, add empty transparent webView over the original webView.

I wrote code like this

Stack(children: [
Opacity(
opacity: 0.01,
child: WebViewWidget(controller: WebViewController())
),
const CircularProgressIndicator(),
]);

This works fine so far.

@zzh3321
Copy link
zzh3321 commented Jun 2, 2023

@kcisoul this is really wonderful!
I don't understand why no one has come out to explain or track this issue for 3 years

@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
@Hixie Hixie removed the plugin label Jul 6, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Jul 8, 2023
@Frank3K
Copy link
Frank3K commented Jul 27, 2023

We ran into this issue too on both iOS and Android, even though it was mentioned in this thread more than once that the issue does not occur on Android. Our main use case for this issue is Chromebooks (running the Android build) where a hardware mouse is always present. When something (e.g. a modal) is drawn on top of a webview, the webview still captures pointer events (e.g. clicks).

Inspired by the comment from @kcisoul we created a fork of pointer_interceptor which contains a work-around for both iOS and Android. The package itself already has support for Web.

@Nicholas86
Copy link

@kcisoul 这真是太棒了! 我不明白为什么三年来没有人出来解释或跟踪这个问题

遇到同样的问题。使用你的方案,解决了。感谢。

@kobi666
Copy link
kobi666 commented Mar 17, 2024

@darshankawar
can we at least have an explanation to this behavior?
like what's the underlying cause of this?

@swiftymf
Copy link
swiftymf commented Sep 23, 2024

We ran into this issue too on both iOS and Android, even though it was mentioned in this thread more than once that the issue does not occur on Android. Our main use case for this issue is Chromebooks (running the Android build) where a hardware mouse is always present. When something (e.g. a modal) is drawn on top of a webview, the webview still captures pointer events (e.g. clicks).

Inspired by the comment from @kcisoul we created a fork of pointer_interceptor which contains a work-around for both iOS and Android. The package itself already has support for Web.

Is this workaround still working for people? I tried wrapping this is my code and it doesn't seem to be working. This is what my custom widget build method returns and then I wrap that in a GestureDetector with a log when tapped and I'm don't see the log appear.

return AspectRatio( aspectRatio: 16.0 / 9.0, child: Stack( children: [ WebViewWidget(controller: controller), GestureDetector( behavior: HitTestBehavior.translucent, onTap: () => sendEventMethod()), ], ), )

EDIT:
My issue was trying to use GestureDetector to send an event when the WebView was tapped. Wrapping the WebView widget in a GestureDetector didn't work for me because the WebView would consume all the taps and not allow the parent to detect them. Doing this Stack approach made it work for me, I didn't need to use the Opacity widget.

@Hilbert2048
Copy link

I put a ModalBottomSheetRoute overlay on top of a WebView, and PointerInterceptor effectively resolved my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: gestures flutter/packages/flutter/gestures repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on p: webview The WebView plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests

0