Skip to content

Commit

Permalink
fix: ensure hardware pointer events do not reach underlying webview
Browse files Browse the repository at this point in the history
This fixes the issue on iOS and Android (including Chromebook) where hardware mouse events were being captured by an underlying webview.
  • Loading branch information
Frank3K committed Jul 26, 2023
1 parent a99fc87 commit db205f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/pointer_interceptor/lib/src/mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:flutter/widgets.dart';
import 'package:webview_flutter/webview_flutter.dart';

/// A [Widget] that prevents clicks from being swallowed by [HtmlElementView]s.
class PointerInterceptor extends StatelessWidget {
Expand All @@ -29,6 +32,16 @@ class PointerInterceptor extends StatelessWidget {

@override
Widget build(BuildContext context) {
return child;
if (Platform.isAndroid || Platform.isIOS) {
return Stack(alignment: Alignment.center, children: <Widget>[
Opacity(
opacity: 0,
child: WebViewWidget(controller: WebViewController()),
),
child,
]);
} else {
return child;
}
}
}
1 change: 1 addition & 0 deletions packages/pointer_interceptor/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
webview_flutter: ^4.0.7

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit db205f1

Please sign in to comment.