diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index b6bd289b..fefd2bec 100755
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -85,5 +85,11 @@
android:resource="@xml/provider_paths"/>
+
+
+
+
diff --git a/lib/src/in_app_webview.dart b/lib/src/in_app_webview.dart
index c031c3f3..19462ba9 100755
--- a/lib/src/in_app_webview.dart
+++ b/lib/src/in_app_webview.dart
@@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart';
@@ -339,41 +340,37 @@ class _InAppWebViewState extends State {
@override
Widget build(BuildContext context) {
if (defaultTargetPlatform == TargetPlatform.android) {
- return AndroidView(
+ return PlatformViewLink(
viewType: 'com.pichillilorenzo/flutter_inappwebview',
- onPlatformViewCreated: _onPlatformViewCreated,
- gestureRecognizers: widget.gestureRecognizers,
- layoutDirection: TextDirection.rtl,
- creationParams: {
- 'initialUrl': '${Uri.parse(widget.initialUrl)}',
- 'initialFile': widget.initialFile,
- 'initialData': widget.initialData?.toMap(),
- 'initialHeaders': widget.initialHeaders,
- 'initialOptions': widget.initialOptions?.toMap() ?? {},
- 'contextMenu': widget.contextMenu?.toMap() ?? {},
- 'windowId': widget.windowId
+ surfaceFactory: (
+ BuildContext context,
+ PlatformViewController controller,
+ ) {
+ return AndroidViewSurface(
+ controller: controller,
+ gestureRecognizers: widget.gestureRecognizers ?? const >{},
+ hitTestBehavior: PlatformViewHitTestBehavior.opaque,
+ );
+ },
+ onCreatePlatformView: (PlatformViewCreationParams params) {
+ return PlatformViewsService.initSurfaceAndroidView(
+ id: params.id,
+ viewType: 'com.pichillilorenzo/flutter_inappwebview',
+ layoutDirection: TextDirection.rtl,
+ creationParams: {
+ 'initialUrl': '${Uri.parse(widget.initialUrl)}',
+ 'initialFile': widget.initialFile,
+ 'initialData': widget.initialData?.toMap(),
+ 'initialHeaders': widget.initialHeaders,
+ 'initialOptions': widget.initialOptions?.toMap() ?? {}
+ },
+ creationParamsCodec: const StandardMessageCodec(),
+ )
+ ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
+ ..addOnPlatformViewCreatedListener((id) => _onPlatformViewCreated(id))
+ ..create();
},
- creationParamsCodec: const StandardMessageCodec(),
);
- // onLongPress issue: https://github.com/flutter/plugins/blob/f31d16a6ca0c4bd6849cff925a00b6823973696b/packages/webview_flutter/lib/src/webview_android.dart#L31
- /*return GestureDetector(
- onLongPress: () {},
- excludeFromSemantics: true,
- child: AndroidView(
- viewType: 'com.pichillilorenzo/flutter_inappwebview',
- onPlatformViewCreated: _onPlatformViewCreated,
- gestureRecognizers: widget.gestureRecognizers,
- layoutDirection: TextDirection.rtl,
- creationParams: {
- 'initialUrl': '${Uri.parse(widget.initialUrl)}',
- 'initialFile': widget.initialFile,
- 'initialData': widget.initialData?.toMap(),
- 'initialHeaders': widget.initialHeaders,
- 'initialOptions': initialOptions
- },
- creationParamsCodec: const StandardMessageCodec(),
- ),
- );*/
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return UiKitView(
viewType: 'com.pichillilorenzo/flutter_inappwebview',