From 94c9394addfd8f198f6a650ded596e9d42b5e151 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 31 Jan 2023 16:10:17 -0500 Subject: [PATCH 01/12] implementation of the webViewIdentifier field --- .../webview_flutter_android/CHANGELOG.md | 4 ++ .../webviewflutter/WebViewFlutterPlugin.java | 42 ++++++++++++++++++- .../WebViewFlutterPluginTest.java | 21 +++++++++- .../lib/src/android_webview_controller.dart | 10 +++++ .../webview_flutter_android/pubspec.yaml | 2 +- .../test/android_webview_controller_test.dart | 24 +++++++++++ .../webview_flutter_wkwebview/CHANGELOG.md | 4 ++ .../FLTWebViewFlutterPluginTests.m | 27 ++++++++++++ .../ios/Classes/FLTWebViewFlutterPlugin.h | 20 +++++++++ .../ios/Classes/FLTWebViewFlutterPlugin.m | 13 ++++++ .../lib/src/webkit_webview_controller.dart | 10 +++++ .../webview_flutter_wkwebview/pubspec.yaml | 2 +- .../test/webkit_webview_controller_test.dart | 20 +++++++++ 13 files changed, 193 insertions(+), 6 deletions(-) create mode 100644 packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FLTWebViewFlutterPluginTests.m diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md index 136d71485a0f..ed6c546ed147 100644 --- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.3.0 + +* Adds support to access native `WebView`. + ## 3.2.4 * Renames Pigeon output files. diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java index 1c5a55057ca6..951a6ebfdffd 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java @@ -7,8 +7,11 @@ import android.content.Context; import android.os.Handler; import android.view.View; +import android.webkit.WebView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; +import io.flutter.embedding.engine.FlutterEngine; import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.embedding.engine.plugins.activity.ActivityAware; import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; @@ -33,12 +36,43 @@ *
Call {@link #registerWith} to use the stable {@code io.flutter.plugin.common} package instead. */ public class WebViewFlutterPlugin implements FlutterPlugin, ActivityAware { - private InstanceManager instanceManager; + @Nullable private InstanceManager instanceManager; private FlutterPluginBinding pluginBinding; private WebViewHostApiImpl webViewHostApi; private JavaScriptChannelHostApiImpl javaScriptChannelHostApi; + /** + * Retrieves the {@link WebView} that is associated with `identifer`. + * + *
See the Dart method `AndroidWebViewController.webViewIdentifier` to get the identifier of an
+ * underlying `WebView`.
+ *
+ * @param engine the execution environment the {@link WebViewFlutterPlugin} should belong to. If
+ * the engine doesn't contain an attached instance of {@link WebViewFlutterPlugin}, this
+ * method returns null.
+ * @param identifier the associated identifier of the `WebView`.
+ * @return the `WebView` associated with `identifier` or null if a `WebView` instance associated
+ * with `identifier` could not be found.
+ */
+ @SuppressWarnings("unused")
+ @Nullable
+ public static WebView getWebView(FlutterEngine engine, long identifier) {
+ final WebViewFlutterPlugin webViewPlugin =
+ (WebViewFlutterPlugin) engine.getPlugins().get(WebViewFlutterPlugin.class);
+
+ if (webViewPlugin == null || webViewPlugin.instanceManager == null) {
+ return null;
+ }
+
+ final Object instance = webViewPlugin.instanceManager.getInstance(identifier);
+ if (instance instanceof WebView) {
+ return (WebView) instance;
+ }
+
+ return null;
+ }
+
/**
* Add an instance of this to {@link io.flutter.embedding.engine.plugins.PluginRegistry} to
* register it.
@@ -148,7 +182,10 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
- instanceManager.close();
+ if (instanceManager != null) {
+ instanceManager.close();
+ instanceManager = null;
+ }
}
@Override
@@ -179,6 +216,7 @@ private void updateContext(Context context) {
/** Maintains instances used to communicate with the corresponding objects in Dart. */
@Nullable
+ @VisibleForTesting
public InstanceManager getInstanceManager() {
return instanceManager;
}
diff --git a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterPluginTest.java b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterPluginTest.java
index 16dc6cf5de2b..b8cde778708a 100644
--- a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterPluginTest.java
+++ b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterPluginTest.java
@@ -4,11 +4,16 @@
package io.flutter.plugins.webviewflutter;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.webkit.WebView;
+import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
+import io.flutter.embedding.engine.plugins.PluginRegistry;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.platform.PlatformViewRegistry;
import org.junit.Rule;
@@ -29,7 +34,7 @@ public class WebViewFlutterPluginTest {
@Mock FlutterPlugin.FlutterPluginBinding mockPluginBinding;
@Test
- public void getInstanceManagerAfterOnAttachedToEngine() {
+ public void getWebView() {
final WebViewFlutterPlugin webViewFlutterPlugin = new WebViewFlutterPlugin();
when(mockPluginBinding.getApplicationContext()).thenReturn(mockContext);
@@ -38,7 +43,19 @@ public void getInstanceManagerAfterOnAttachedToEngine() {
webViewFlutterPlugin.onAttachedToEngine(mockPluginBinding);
- assertNotNull(webViewFlutterPlugin.getInstanceManager());
+ final InstanceManager instanceManager = webViewFlutterPlugin.getInstanceManager();
+ assertNotNull(instanceManager);
+
+ final WebView mockWebView = mock(WebView.class);
+ instanceManager.addDartCreatedInstance(mockWebView, 0);
+
+ final PluginRegistry mockPluginRegistry = mock(PluginRegistry.class);
+ when(mockPluginRegistry.get(WebViewFlutterPlugin.class)).thenReturn(webViewFlutterPlugin);
+
+ final FlutterEngine mockFlutterEngine = mock(FlutterEngine.class);
+ when(mockFlutterEngine.getPlugins()).thenReturn(mockPluginRegistry);
+
+ assertEquals(WebViewFlutterPlugin.getWebView(mockFlutterEngine, 0), mockWebView);
webViewFlutterPlugin.onDetachedFromEngine(mockPluginBinding);
}
diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart
index fd287a515c65..6bd3dc03746c 100644
--- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart
+++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart
@@ -144,6 +144,16 @@ class AndroidWebViewController extends PlatformWebViewController {
return webViewProxy.setWebContentsDebuggingEnabled(enabled);
}
+ /// Identifier used to retrieve the underlying native `WKWebView`.
+ ///
+ /// This is typically used by other plugins to retrieve the native `WebView`
+ /// from an `InstanceManager`.
+ ///
+ /// See Java method `WebViewFlutterPlugin.getWebView`.
+ int get webViewIdentifier =>
+ // ignore: invalid_use_of_visible_for_testing_member
+ android_webview.WebView.api.instanceManager.getIdentifier(_webView)!;
+
@override
Future See the Dart method `AndroidWebViewController.webViewIdentifier` to get the identifier of an
+ * underlying `WebView`.
+ *
+ * @param engine the execution environment the {@link WebViewFlutterPlugin} should belong to. If
+ * the engine doesn't contain an attached instance of {@link WebViewFlutterPlugin}, this
+ * method returns null.
+ * @param identifier the associated identifier of the `WebView`.
+ * @return the `WebView` associated with `identifier` or null if a `WebView` instance associated
+ * with `identifier` could not be found.
+ */
+ @Nullable
+ static WebView getWebView(FlutterEngine engine, long identifier) {
+ final WebViewFlutterPlugin webViewPlugin =
+ (WebViewFlutterPlugin) engine.getPlugins().get(WebViewFlutterPlugin.class);
+
+ if (webViewPlugin != null && webViewPlugin.getInstanceManager() != null) {
+ final Object instance = webViewPlugin.getInstanceManager().getInstance(identifier);
+ if (instance instanceof WebView) {
+ return (WebView) instance;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java
index 951a6ebfdffd..e34a17d6f60d 100644
--- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java
+++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java
@@ -42,37 +42,6 @@ public class WebViewFlutterPlugin implements FlutterPlugin, ActivityAware {
private WebViewHostApiImpl webViewHostApi;
private JavaScriptChannelHostApiImpl javaScriptChannelHostApi;
- /**
- * Retrieves the {@link WebView} that is associated with `identifer`.
- *
- * See the Dart method `AndroidWebViewController.webViewIdentifier` to get the identifier of an
- * underlying `WebView`.
- *
- * @param engine the execution environment the {@link WebViewFlutterPlugin} should belong to. If
- * the engine doesn't contain an attached instance of {@link WebViewFlutterPlugin}, this
- * method returns null.
- * @param identifier the associated identifier of the `WebView`.
- * @return the `WebView` associated with `identifier` or null if a `WebView` instance associated
- * with `identifier` could not be found.
- */
- @SuppressWarnings("unused")
- @Nullable
- public static WebView getWebView(FlutterEngine engine, long identifier) {
- final WebViewFlutterPlugin webViewPlugin =
- (WebViewFlutterPlugin) engine.getPlugins().get(WebViewFlutterPlugin.class);
-
- if (webViewPlugin == null || webViewPlugin.instanceManager == null) {
- return null;
- }
-
- final Object instance = webViewPlugin.instanceManager.getInstance(identifier);
- if (instance instanceof WebView) {
- return (WebView) instance;
- }
-
- return null;
- }
-
/**
* Add an instance of this to {@link io.flutter.embedding.engine.plugins.PluginRegistry} to
* register it.
@@ -216,7 +185,6 @@ private void updateContext(Context context) {
/** Maintains instances used to communicate with the corresponding objects in Dart. */
@Nullable
- @VisibleForTesting
public InstanceManager getInstanceManager() {
return instanceManager;
}
diff --git a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterPluginTest.java b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApiTest.java
similarity index 82%
rename from packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterPluginTest.java
rename to packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApiTest.java
index b8cde778708a..8c90d4dc31ef 100644
--- a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterPluginTest.java
+++ b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApiTest.java
@@ -11,27 +11,34 @@
import android.content.Context;
import android.webkit.WebView;
-import io.flutter.embedding.engine.FlutterEngine;
-import io.flutter.embedding.engine.plugins.FlutterPlugin;
-import io.flutter.embedding.engine.plugins.PluginRegistry;
-import io.flutter.plugin.common.BinaryMessenger;
-import io.flutter.plugin.platform.PlatformViewRegistry;
+
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
-public class WebViewFlutterPluginTest {
- @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
+import io.flutter.embedding.engine.FlutterEngine;
+import io.flutter.embedding.engine.plugins.FlutterPlugin;
+import io.flutter.embedding.engine.plugins.PluginRegistry;
+import io.flutter.plugin.common.BinaryMessenger;
+import io.flutter.plugin.platform.PlatformViewRegistry;
+
+public class WebViewFlutterAndroidExternalApiTest {
+ @Rule
+ public MockitoRule mockitoRule = MockitoJUnit.rule();
- @Mock Context mockContext;
+ @Mock
+ Context mockContext;
- @Mock BinaryMessenger mockBinaryMessenger;
+ @Mock
+ BinaryMessenger mockBinaryMessenger;
- @Mock PlatformViewRegistry mockViewRegistry;
+ @Mock
+ PlatformViewRegistry mockViewRegistry;
- @Mock FlutterPlugin.FlutterPluginBinding mockPluginBinding;
+ @Mock
+ FlutterPlugin.FlutterPluginBinding mockPluginBinding;
@Test
public void getWebView() {
@@ -55,7 +62,7 @@ public void getWebView() {
final FlutterEngine mockFlutterEngine = mock(FlutterEngine.class);
when(mockFlutterEngine.getPlugins()).thenReturn(mockPluginRegistry);
- assertEquals(WebViewFlutterPlugin.getWebView(mockFlutterEngine, 0), mockWebView);
+ assertEquals(WebViewFlutterAndroidExternalApi.getWebView(mockFlutterEngine, 0), mockWebView);
webViewFlutterPlugin.onDetachedFromEngine(mockPluginBinding);
}
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FLTWebViewFlutterPluginTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewFlutterWKWebViewExternalAPITests.m
similarity index 79%
rename from packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FLTWebViewFlutterPluginTests.m
rename to packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewFlutterWKWebViewExternalAPITests.m
index dac932257a81..07e5e3feceb8 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FLTWebViewFlutterPluginTests.m
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewFlutterWKWebViewExternalAPITests.m
@@ -7,10 +7,10 @@
@import webview_flutter_wkwebview;
-@interface FLTWebViewFlutterPluginTests : XCTestCase
+@interface FWFWebViewFlutterWKWebViewExternalAPITests : XCTestCase
@end
-@implementation FLTWebViewFlutterPluginTests
+@implementation FWFWebViewFlutterWKWebViewExternalAPITests
- (void)testWebViewForIdentifier {
WKWebView *webView = [[WKWebView alloc] init];
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init];
@@ -20,7 +20,7 @@ - (void)testWebViewForIdentifier {
OCMStub([mockPluginRegistry valuePublishedByPlugin:@"FLTWebViewFlutterPlugin"])
.andReturn(instanceManager);
- XCTAssertEqualObjects([FLTWebViewFlutterPlugin webViewForIdentifier:0
+ XCTAssertEqualObjects([FWFWebViewFlutterWKWebViewExternalAPI webViewForIdentifier:0
withPluginRegistry:mockPluginRegistry],
webView);
}
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FLTWebViewFlutterPlugin.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FLTWebViewFlutterPlugin.h
index fe640c67abbf..a1c035e40185 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FLTWebViewFlutterPlugin.h
+++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FLTWebViewFlutterPlugin.h
@@ -8,21 +8,6 @@
NS_ASSUME_NONNULL_BEGIN
@interface FLTWebViewFlutterPlugin : NSObject This class follows the convention of breaking changes of the Dart API, which means that any
* changes to the class that are not backwards compatible will only be done with a major version
* change of the plugin.
*/
diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java
index e34a17d6f60d..04a9735e0281 100644
--- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java
+++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.java
@@ -7,11 +7,8 @@
import android.content.Context;
import android.os.Handler;
import android.view.View;
-import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.VisibleForTesting;
-import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
diff --git a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApiTest.java b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApiTest.java
index 8c90d4dc31ef..0877dcaf2b06 100644
--- a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApiTest.java
+++ b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApiTest.java
@@ -11,34 +11,27 @@
import android.content.Context;
import android.webkit.WebView;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.PluginRegistry;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.platform.PlatformViewRegistry;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
public class WebViewFlutterAndroidExternalApiTest {
- @Rule
- public MockitoRule mockitoRule = MockitoJUnit.rule();
+ @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
- @Mock
- Context mockContext;
+ @Mock Context mockContext;
- @Mock
- BinaryMessenger mockBinaryMessenger;
+ @Mock BinaryMessenger mockBinaryMessenger;
- @Mock
- PlatformViewRegistry mockViewRegistry;
+ @Mock PlatformViewRegistry mockViewRegistry;
- @Mock
- FlutterPlugin.FlutterPluginBinding mockPluginBinding;
+ @Mock FlutterPlugin.FlutterPluginBinding mockPluginBinding;
@Test
public void getWebView() {
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewFlutterWKWebViewExternalAPITests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewFlutterWKWebViewExternalAPITests.m
index 07e5e3feceb8..1452edeaa647 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewFlutterWKWebViewExternalAPITests.m
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewFlutterWKWebViewExternalAPITests.m
@@ -20,8 +20,9 @@ - (void)testWebViewForIdentifier {
OCMStub([mockPluginRegistry valuePublishedByPlugin:@"FLTWebViewFlutterPlugin"])
.andReturn(instanceManager);
- XCTAssertEqualObjects([FWFWebViewFlutterWKWebViewExternalAPI webViewForIdentifier:0
- withPluginRegistry:mockPluginRegistry],
- webView);
+ XCTAssertEqualObjects(
+ [FWFWebViewFlutterWKWebViewExternalAPI webViewForIdentifier:0
+ withPluginRegistry:mockPluginRegistry],
+ webView);
}
@end
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
index 3dfa635608b6..5f96fc91e3af 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
+++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
@@ -3,8 +3,8 @@
// found in the LICENSE file.
#import This class follows the convention of breaking changes of the Dart API, which means that any
- * changes to the class that are not backwards compatible will only be done with a major version
+ * changes to the class that are not backwards compatible will only be made with a major version
* change of the plugin.
*/
@SuppressWarnings("unused")
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/README.md b/packages/webview_flutter/webview_flutter_wkwebview/README.md
index 79359636e742..b8e964355948 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/README.md
+++ b/packages/webview_flutter/webview_flutter_wkwebview/README.md
@@ -7,6 +7,22 @@ The Apple WKWebView implementation of [`webview_flutter`][1].
This package is [endorsed][2], which means you can simply use `webview_flutter`
normally. This package will be automatically included in your app when you do.
+### External Native API
+
+The plugin also provides a native API for interacting for Android applications. This API follows the
+convention of breaking changes of the Dart API, which means that any changes to the class that are
+not backwards compatible will only be made with a major version change of the plugin.
+
+The API can be accessed by importing the native plugin `webview_flutter_wkwebview`:
+
+Objective-C:
+
+```objectivec
+@import webview_flutter_wkwebview;
+```
+
+Then you will have access to the native class `FWFWebViewFlutterWKWebViewExternalAPI`.
+
## Contributing
This package uses [pigeon][3] to generate the communication layer between Flutter and the host
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
index 5f96fc91e3af..6372f986f82a 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
+++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
App and package facing native API provided by the `webview_flutter_wkwebview` plugin.
This class follows the convention of breaking changes of the Dart API, which means that any
-changes to the class that are not backwards compatible will only be done with a major version
+changes to the class that are not backwards compatible will only be made with a major version
change of the plugin.
*/
@interface FWFWebViewFlutterWKWebViewExternalAPI : NSObject
From 4b580c3ea86208bb926a062e004146c6be6f24f7 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 8 Feb 2023 16:13:40 -0500
Subject: [PATCH 05/12] iOS
---
packages/webview_flutter/webview_flutter_wkwebview/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/README.md b/packages/webview_flutter/webview_flutter_wkwebview/README.md
index b8e964355948..b644f2c7da7d 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/README.md
+++ b/packages/webview_flutter/webview_flutter_wkwebview/README.md
@@ -9,7 +9,7 @@ normally. This package will be automatically included in your app when you do.
### External Native API
-The plugin also provides a native API for interacting for Android applications. This API follows the
+The plugin also provides a native API for interacting for iOS applications. This API follows the
convention of breaking changes of the Dart API, which means that any changes to the class that are
not backwards compatible will only be made with a major version change of the plugin.
From c75a52cfa516a5a4f61acf47647b345d564729ee Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 8 Feb 2023 16:14:35 -0500
Subject: [PATCH 06/12] improve
---
packages/webview_flutter/webview_flutter_android/README.md | 2 +-
packages/webview_flutter/webview_flutter_wkwebview/README.md | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_android/README.md b/packages/webview_flutter/webview_flutter_android/README.md
index f5deb76c6f92..006add631543 100644
--- a/packages/webview_flutter/webview_flutter_android/README.md
+++ b/packages/webview_flutter/webview_flutter_android/README.md
@@ -34,7 +34,7 @@ for more details on setting platform-specific features in the main plugin.
### External Native API
-The plugin also provides a native API for interacting for Android applications. This API follows the
+The plugin also provides a native API for interacting with Android applications. This API follows the
convention of breaking changes of the Dart API, which means that any changes to the class that are
not backwards compatible will only be made with a major version change of the plugin.
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/README.md b/packages/webview_flutter/webview_flutter_wkwebview/README.md
index b644f2c7da7d..5bc03791899a 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/README.md
+++ b/packages/webview_flutter/webview_flutter_wkwebview/README.md
@@ -9,7 +9,7 @@ normally. This package will be automatically included in your app when you do.
### External Native API
-The plugin also provides a native API for interacting for iOS applications. This API follows the
+The plugin also provides a native API for interacting with iOS applications. This API follows the
convention of breaking changes of the Dart API, which means that any changes to the class that are
not backwards compatible will only be made with a major version change of the plugin.
From 676fcdc775c90eff37d0c2b81863364be196bfab Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 8 Feb 2023 16:16:35 -0500
Subject: [PATCH 07/12] hmmmm
---
packages/webview_flutter/webview_flutter_android/README.md | 7 ++++---
.../webview_flutter/webview_flutter_wkwebview/README.md | 7 ++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_android/README.md b/packages/webview_flutter/webview_flutter_android/README.md
index 006add631543..7ab2b494c676 100644
--- a/packages/webview_flutter/webview_flutter_android/README.md
+++ b/packages/webview_flutter/webview_flutter_android/README.md
@@ -34,9 +34,10 @@ for more details on setting platform-specific features in the main plugin.
### External Native API
-The plugin also provides a native API for interacting with Android applications. This API follows the
-convention of breaking changes of the Dart API, which means that any changes to the class that are
-not backwards compatible will only be made with a major version change of the plugin.
+The plugin also provides a native API accessible by the native code of Android applications or
+packages. This API follows the convention of breaking changes of the Dart API, which means that any
+changes to the class that are not backwards compatible will only be made with a major version change
+of the plugin.
The API can be accessed by importing the native class `WebViewFlutterAndroidExternalApi`.:
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/README.md b/packages/webview_flutter/webview_flutter_wkwebview/README.md
index 5bc03791899a..2a20e40712fa 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/README.md
+++ b/packages/webview_flutter/webview_flutter_wkwebview/README.md
@@ -9,9 +9,10 @@ normally. This package will be automatically included in your app when you do.
### External Native API
-The plugin also provides a native API for interacting with iOS applications. This API follows the
-convention of breaking changes of the Dart API, which means that any changes to the class that are
-not backwards compatible will only be made with a major version change of the plugin.
+The plugin also provides a native API accessible by the native code of iOS applications or packages.
+This API follows the convention of breaking changes of the Dart API, which means that any changes to
+the class that are not backwards compatible will only be made with a major version change of the
+plugin.
The API can be accessed by importing the native plugin `webview_flutter_wkwebview`:
From f463dacd375c6698bc1e46d17bb1788bbc8cc48d Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Fri, 10 Feb 2023 14:36:00 -0500
Subject: [PATCH 08/12] add note about not using other apis
---
packages/webview_flutter/webview_flutter_android/README.md | 5 +++--
.../webviewflutter/WebViewFlutterAndroidExternalApi.java | 3 +++
packages/webview_flutter/webview_flutter_wkwebview/README.md | 3 ++-
.../ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h | 3 ++-
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_android/README.md b/packages/webview_flutter/webview_flutter_android/README.md
index 7ab2b494c676..d2f4d94bfed4 100644
--- a/packages/webview_flutter/webview_flutter_android/README.md
+++ b/packages/webview_flutter/webview_flutter_android/README.md
@@ -37,9 +37,10 @@ for more details on setting platform-specific features in the main plugin.
The plugin also provides a native API accessible by the native code of Android applications or
packages. This API follows the convention of breaking changes of the Dart API, which means that any
changes to the class that are not backwards compatible will only be made with a major version change
-of the plugin.
+of the plugin. Native code other than this external API does not follow breaking change conventions,
+so app or plugin clients should not use any other native APIs.
-The API can be accessed by importing the native class `WebViewFlutterAndroidExternalApi`.:
+The API can be accessed by importing the native class `WebViewFlutterAndroidExternalApi`:
Java:
diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApi.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApi.java
index b400fc5098a6..3819d7b26f62 100644
--- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApi.java
+++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewFlutterAndroidExternalApi.java
@@ -14,6 +14,9 @@
* This class follows the convention of breaking changes of the Dart API, which means that any
* changes to the class that are not backwards compatible will only be made with a major version
* change of the plugin.
+ *
+ * Native code other than this external API does not follow breaking change conventions, so app
+ * or plugin clients should not use any other native APIs.
*/
@SuppressWarnings("unused")
public interface WebViewFlutterAndroidExternalApi {
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/README.md b/packages/webview_flutter/webview_flutter_wkwebview/README.md
index 2a20e40712fa..a393a71d2248 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/README.md
+++ b/packages/webview_flutter/webview_flutter_wkwebview/README.md
@@ -12,7 +12,8 @@ normally. This package will be automatically included in your app when you do.
The plugin also provides a native API accessible by the native code of iOS applications or packages.
This API follows the convention of breaking changes of the Dart API, which means that any changes to
the class that are not backwards compatible will only be made with a major version change of the
-plugin.
+plugin. Native code other than this external API does not follow breaking change conventions, so
+app or plugin clients should not use any other native APIs.
The API can be accessed by importing the native plugin `webview_flutter_wkwebview`:
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
index 6372f986f82a..f0a6477a979f 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
+++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewFlutterWKWebViewExternalAPI.h
@@ -13,7 +13,8 @@ App and package facing native API provided by the `webview_flutter_wkwebview` pl
This class follows the convention of breaking changes of the Dart API, which means that any
changes to the class that are not backwards compatible will only be made with a major version
-change of the plugin.
+change of the plugin. Native code other than this external API does not follow breaking change
+conventions, so app or plugin clients should not use any other native APIs.
*/
@interface FWFWebViewFlutterWKWebViewExternalAPI : NSObject
/**
From b9aa957764c07d3d3ba3335d36105042abacdda6 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Fri, 10 Feb 2023 14:36:08 -0500
Subject: [PATCH 09/12] project changes
---
.../example/ios/Runner.xcodeproj/project.pbxproj | 5 ++++-
.../webview_flutter_wkwebview/example/ios/Runner/Info.plist | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
index 1efee8f844ef..a1040b16e95a 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 50;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -379,10 +379,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
+ "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
@@ -415,6 +417,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist
index bea41604e8aa..6ee44fd0e2fd 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist
@@ -43,5 +43,7 @@