flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.13k stars 27.47k forks source link

IOS only - Underlining webview is intercepting pointer events of widgets above it in Stack #144717

Closed kobi666 closed 8 months ago

kobi666 commented 8 months ago

Steps to reproduce

  1. Create a scafflold with its body being a webView (either using flutter webview or using InAppWebView) and navigate to a site with very critical pointer events, like a map web application (i am attaching an HTML you can use locally to easily reproduce using a floating action button)
  2. add a floating action button
  3. press on the button and see how it may change the interaction on the map

it is important to note that the issue I am experiencing also has to do with the web app | safari "holding" onto the pointer event, but the bug is that the pointer event should not have propagated to the webview in the first place

Expected results

the webview which is lower in the stack (behind the floating action button) should not have received the pointer event at all.

Actual results

the webview is receiving the pointer event coming from the tap on the floating button

Code sample

Code sample ```dart // this also contains the workaround of using an underlining NoPointer widget in the stack to prevent the pointer from //propogating the pointer event import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; class TestingPageWebView extends StatefulWidget { @override State createState() => _TestingPageWebViewState(); } class _TestingPageWebViewState extends State { InAppWebViewSettings settings = InAppWebViewSettings( javaScriptEnabled: true, isInspectable: true, useHybridComposition: true); InAppWebViewController? controller; String htmlString = ''; @override void initState() { // TODO: implement initState super.initState(); } Future Init() async { htmlString = await rootBundle.loadString('assets/watch-for-changes.html'); } bool testPointer = true; @override Widget build(BuildContext context) { // TODO: implement build return FutureBuilder( future: Init(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { return Scaffold( appBar: AppBar( title: Text("Testing")), floatingActionButton: Stack( children: [ Container( color: Color.fromARGB(80, 181, 7, 255), height: 60, width: 60, child: testPointer ? IgnorePointer() : Container()), FloatingActionButton( child: Container(height: 60, width: 60, color: Colors.green, child: Center(child: Icon(Icons.radio_button_checked),),), onPressed: () { print("button tapped"); }), ]), // Stack( // children: [IgnorePointer( // child: Container(height: 60, width: 60, color: Colors.amber,), // ), // // FloatingActionButton(onPressed: () { // // print("Pressed"); // // }) // ], // ), body: Container(color: Colors.amber, child: InAppWebView( gestureRecognizers: [new Factory( () => new EagerGestureRecognizer(), ),].toSet(), //initialUrlRequest: URLRequest(url: WebUri("https://developers.arcgis.com/javascript/latest/sample-code/watch-for-changes/live/")), initialData: InAppWebViewInitialData(data: htmlString), onWebViewCreated: (c) { controller = c; }, initialSettings: settings, ), ), ); } else { return Container(color: Colors.blueGrey); } } ); } } ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs nothing to log i'm afraid

Flutter Doctor output

Doctor output ```console ✓] Flutter (Channel stable, 3.16.5, on macOS 14.2 23C64 darwin-arm64 (Rosetta), locale en-IL) • Flutter version 3.16.5 on channel stable at /Applications/frameworks/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 78666c8dc5 (3 months ago), 2023-12-19 16:14:14 -0800 • Engine revision 3f3e560236 • Dart version 3.2.3 • DevTools version 2.28.4 [✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use `flutter config --android-sdk` to update to that location. [✓] Xcode - develop for iOS and macOS (Xcode 15.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C500b • CocoaPods version 1.15.2 [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions). [✓] VS Code (version 1.86.2) • VS Code at /Users/kobihanma/Downloads/Visual Studio Code.app/Contents • Flutter extension version 3.84.0 [✓] Connected device (1 available) • macOS (desktop) • macos • darwin-arm64 • macOS 14.2 23C64 darwin-arm64 (Rosetta) [✓] Network resources • All expected network resources are available. ```
kobi666 commented 8 months ago

HTML for the local site to reproduce the issue (save as HTML):

<!DOCTYPE html>

Watch for changes | Sample | ArcGIS Maps SDK for JavaScript 4.28
kobi666 commented 8 months ago

HTML for local site: watch-for-changes.html.zip

Testing Page: TestingPage.dart.zip

huycozy commented 8 months ago

Closing as a duplicate of https://github.com/flutter/flutter/issues/58659. Please follow up on it for further updates. Thanks!

github-actions[bot] commented 7 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.