Skip to content

Widgets are not interactable when stacked on top of a WebViewWidget in web. #123343

Open

Description

@willov

It appears that stacking widget on top of a WebViewWidget does not work in the web version.
I have also tested this on Android, and there stacking widgets on top of WebViewWidget does appear to work.
I also tried using another WebView package web_browser, but the same behaviour occurs.

Steps to Reproduce

  1. Install webview_flutter_web (0.2.2+1) webview_flutter
  2. Execute flutter run on the code sample using Chrome (see "Code sample" section below)
  3. Click "Webview with icon test" button
  4. Interact with widgets (back button, visibility icon)

Expected results:

Interactivity with the widgets, such as returning when using the back button, or switching the visibility symbol to a visibility_off symbol.

Actual results:
No interactivity. The back button sometimes show the "hover over" effect.

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

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Builder(
        builder: (context) => Scaffold(
          body: Center(
            child: Card(
              child: ListTile(
                  title: const Text(
                    'Webview with icon test',
                  ),
                  onTap: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (BuildContext context) {
                          return const WebViewPage();
                        },
                      ),
                    );
                  }),
            ),
          ),
        ),
      ),
    );
  }
}

class WebViewPage extends StatefulWidget {
  const WebViewPage({Key? key}) : super(key: key);

  @override
  State<WebViewPage> createState() => _WebViewPageState();
}

class _WebViewPageState extends State<WebViewPage> {
  late final WebViewController _controller;

  @override
  void initState() {
    super.initState();
    _controller = WebViewController()
      ..loadRequest(
        Uri.parse('http://flutter.dev'),
      );
  }

  bool visibilityIsPressed = false;
  @override
  Widget build(BuildContext context) {
    final ColorScheme colors = Theme.of(context).colorScheme;

    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        iconTheme: IconThemeData(
          color: colors.primary, 
        ),
        backgroundColor: Colors.transparent,
      ),
      body: Stack(
        children: [
          WebViewWidget(controller: _controller),
          // Browser(initialUriString: 'https://flutter.dev/',), //Another package with the same issue
          SafeArea(
            child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  IconButton(
                    iconSize: 30,
                    icon: (visibilityIsPressed)
                        ? const Icon(Icons.visibility_off_outlined)
                        : const Icon(Icons.visibility_outlined),
                    onPressed: () {
                      setState(() {
                        visibilityIsPressed = !visibilityIsPressed;
                      });
                    },
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Logs

The verbose log is too long to attach in the text so it is attached as a separate file.
run_verbose.txt

Analyzing flutter_application_1...                                      
No issues found! (ran in 1.0s)
[✓] Flutter (Channel stable, 3.7.6, on Ubuntu 22.10 5.14.0-1034-oem, locale en_US.UTF-8)
    • Flutter version 3.7.6 on channel stable at /home/william/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 12cb4eb7a0 (3 weeks ago), 2023-03-01 10:29:26 -0800
    • Engine revision ada363ee93
    • Dart version 2.19.3
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /home/william/Android/Sdk
    • Platform android-33-ext4, build-tools 33.0.2
    • Java binary at: /snap/android-studio/125/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /snap/bin/chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1
[run_verbose.txt](https://github.com/flutter/flutter/files/11054321/run_verbose.txt)


[✓] Android Studio (version 2021.3)
    • Android Studio at /snap/android-studio/125/android-studio
    • 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.13+0-b1751.21-8125866)

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension version 3.60.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.10 5.14.0-1034-oem
    • Chrome (web)    • chrome • web-javascript • Chromium 111.0.5563.64 snap

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

• No issues found!

Activity

  1. darshankawar commented on Mar 24, 2023

    @darshankawar
    Member

    @willov
    Thanks for the report. You mentioned webview_flutter_web and in code sample you used webview_flutter, so could you clarify this ?
    We know that webview_flutter_web is web implementation of the plugin, but would be helpful to know if this is related to webview_flutter itself or with _web version of the plugin.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 24, 2023
  3. willov commented on Mar 24, 2023

    @willov
    Author

    I was under the impression that webview_flutter_web was needed to run webviews in a web application.
    But you are correct that it was not included in the code sample. Furthermore, removing webview_flutter_web from the pubspec.yml and runningflutter pub clean still allows the application to run. So, I assume that that webview_flutter_web was indeed not used. Sorry for the mixup!

    Still, it is not possible to interact with the stacked widgets in the web application (when using the webview_flutter package).

    I have uploaded the full small example to this repository: https://github.com/willov/flutter_webview_issue_example

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 24, 2023
  5. darshankawar commented on Mar 27, 2023

    @darshankawar
    Member

    Thanks for the update. I verified this behavior on web and on mobile and confirmed that the reported behavior occurs on web, ie, tapping on stacked widgets like back button or eye icon don't perform any action, as they are placed over the webview.
    Whereas, the same interactions occur on mobile platform (Android). I don't see an existing issue for web platform for same behavior, so labeling as such.

    stable, master flutter doctor -v
    [!] Flutter (Channel stable, 3.7.7, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.7.7 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 2ad6cd72c0 (12 days ago), 2023-03-08 09:41:59 -0800
        • Engine revision 1837b5be5f
        • Dart version 2.19.4
        • DevTools version 2.20.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.9.0-16.0.pre.42, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.9.0-16.0.pre.42 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision a8afbfa22e (47 minutes ago), 2023-03-24 00:00:20 -0400
        • Engine revision 1da070c57c
        • Dart version 3.0.0 (build 3.0.0-362.0.dev)
        • DevTools version 2.22.2
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at /Users/dhs/Library/Android/sdk
        ✗ cmdline-tools component is missing
          Run `path/to/sdkmanager --install "cmdline-tools;latest"`
          See https://developer.android.com/studio/command-line for more details.
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for
          more details.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 13C100
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA.app
        • Flutter plugin version 65.1.4
        • Dart plugin version 213.7228
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.29.0
    
    [✓] Connected device (3 available)
        • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
          • iOS 15.3.1 19D52
        • macOS (desktop)           • macos                                    •
          darwin-x64     • macOS 12.2.1 21D62 darwin-x64
        • Chrome (web)              • chrome                                   •
          web-javascript • Google Chrome 109.0.5414.119
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
          
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  6. added
    platform-webWeb applications specifically
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Mar 27, 2023
  7. stuartmorgan-g commented on Mar 28, 2023

    @stuartmorgan-g
    Contributor

    @ditman Is this a duplicate?

  8. ditman commented on Mar 28, 2023

    @ditman
    Member

    ... stacking widgets on top of a WebViewWidget does not work in the web version...

    @willov, @stuartmorgan, @darshankawar: I think this is solved by wrapping the widgets that are stacked on top of the HtmlElementView in a PointerInterceptor widget from package:pointer_interceptor (which will noop in mobile). Take a look at the package here:

    (In the future we want to promote the package to the framework, and automate its usage in several places, but for now it's a separate thing).

    @willov let me know if this solves your issue!

  9. 4 remaining items

  10. added
    engineflutter/engine related. See also e: labels.
    on Mar 28, 2023
  11. willov commented on Mar 30, 2023

    @willov
    Author

    @ditman wrapping the widgets in the pointer_interceptor package does indeed solve the issue in the web application. Perhaps obviously, I had to include a leading icon with an onPressed action to get the back button to be intractable.

    Perhaps mentioning this pointer_interceptor package on the webview_flutter page would be a good idea?

    Either way, big thanks for pointing out the solution!

  12. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 30, 2023
  13. added
    P3Issues that are less important to the Flutter project
    on Mar 30, 2023
  14. yjbanov commented on Mar 30, 2023

    @yjbanov
    Contributor

    For now making it a documentation issue, but we should consider moving pointer interceptor into the framework, so that:

    • All built-in overlays - dialogs, menus, app bars, drawers - use it automatically.
    • It's available without needing an extra package.
  15. khaled-0 commented on Jan 20, 2026

    @khaled-0

    Meanwhile another thing is happening in MacOS 26
    Flutter 3.38.7

    The WebView itself is not interactive when I wrap it in a Card.outlined

    
    class AuthDialog extends StatefulWidget {
      const AuthDialog({super.key});
    
      @override
      State<AuthDialog> createState() => _AuthDialogState();
    }
    
    class _AuthDialogState extends State<AuthDialog> {
      late final store = context.read<Store>();
      late final WebViewController controller = WebViewController()
        ..setJavaScriptMode(JavaScriptMode.unrestricted)
        ..loadRequest(Uri.parse("https://google.com"));
    
      @override
      Widget build(BuildContext context) {
        /// Click Does not Work
        return Card.outlined(
          child: WebViewWidget(
            controller: controller,
          ),
        );
    
        /// Click Works
        return Card(
          child: WebViewWidget(controller: controller),
        );
        
        /// Click Works
        return Padding(
          padding: const EdgeInsets.only(bottom: 8, left: 8, right: 8),
          child: DecoratedBox(
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(12)),
            child: WebViewWidget(controller: controller),
          ),
        );
      }
    }
    

    Upon further investigation it seems adding border on foreground makes it not clickable anymore

  16. ditman commented on Jan 20, 2026

    @ditman
    Member

    @khaled-0 I think the issue you're describing got fixed here:

    If not, please create a new issue, do not revive such an old issue please!

  17. khaled-0 commented on Jan 21, 2026

    @khaled-0

    @khaled-0 I think the issue you're describing got fixed here:

    If not, please create a new issue, do not revive such an old issue please!

    nope, I just tried the master branch and the issue persist.
    I'll go ahead and open a separate bug report #181257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectd: api docsIssues with https://api.flutter.dev/engineflutter/engine related. See also e: labels.found in release: 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions