[webview] Add new method for cross plugin webview access#11714
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces new methods to access native WebView (Android) and WKWebView (iOS/macOS) instances using FlutterPluginBinding and FlutterPluginRegistrar, respectively, while deprecating the previous engine and registry-based approaches. The changes include updated unit tests and a minimum Flutter version bump to 3.44.0 for both packages. Review feedback identifies a pluralization inconsistency in the wkwebview changelog and an unnecessary downgrade of the Dart SDK constraint in its pubspec.yaml.
A new way of supporting cross plugin communication is coming in Flutter 3.44 which allows for access to plugin published values through the `FlutterPluginBinding` on Android and the `FlutterPluginRegistry` on iOS. Update native WebView access to support these new methods and deprecate the old methods. refs: flutter/flutter#121527 flutter/flutter#182753 # Conflicts: # packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml
796dc17 to
c4d49c6
Compare
| environment: | ||
| sdk: ^3.10.0 | ||
| flutter: ">=3.38.0" | ||
| flutter: ">=3.44.0" |
There was a problem hiding this comment.
@stuartmorgan-g Does this PR need to wait until we bump all the plugins in the repo to 3.44? This isn't fixing a bug, so I don't think it is an exemption to support n-2 stable version.
There was a problem hiding this comment.
We don't require supporting N-2, we just don't allow supporting things older than N-2. We only require supporting stable.
This will need wait until Flutter master rolls to a version that reports being newer than a 3.44 pre-release though so that the resolver works (the usual problem we have with master right after a release).
| final WebViewFlutterPlugin webViewPlugin = | ||
| (WebViewFlutterPlugin) binding.getPlugin(WebViewFlutterPlugin.class); | ||
|
|
||
| if (webViewPlugin != null && webViewPlugin.getInstanceManager() != null) { |
There was a problem hiding this comment.
Everything from here on can be extracted to a private helper instead of duplicated.
| version: 4.13.0 | ||
|
|
||
| environment: | ||
| sdk: ^3.9.0 |
There was a problem hiding this comment.
We require that the Dart and Flutter versions align in our packages, so this needs to be updated as well.
|
We've rolled 3.44 |
# Conflicts: # packages/webview_flutter/webview_flutter_android/CHANGELOG.md # packages/webview_flutter/webview_flutter_android/pubspec.yaml
|
😬 When updating this it looks like there's a secondary problem. While Thoughts on the correct solution here? I can go in and add the I could mark the external method as iOS only for time being, then add the required method to macOS later... Suggestions @stuartmorgan-g ? Also question about the |
That's the simplest path forward; the pressing use case I'm aware of for this API is on iOS, so fixing it there faster is worth the temporary mismatch. The ifdef should have a TODO comment explaining why it's ifdef'd out, and linking to an issue filed to track adding the API to the macOS engine.
|
|
Looks like the min Dart SDK bump picked up some minor analyzer issues that will need to be fixed (due to a new Dart feature being available). |
|
|
|
Are you on a very recent To make sure you match, you can temporarily sync your local Flutter to this version and then format.) |
|
I was actually on Flutter Stable (3.44). Syncing to that commit and reformatting did make some changes, so hopefully it's now correct. |
|
autosubmit label was removed for flutter/packages/11714, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
|
Oops, I thought @bparrishMines had already approved this. |
bparrishMines
left a comment
There was a problem hiding this comment.
LGTM
Sorry for the delay, I can handle the version bumps.
…r#187612) flutter/packages@03352b5...61bdbb4 2026-06-04 stuartmorgan@google.com [tool] Use `flutter` for pub commands when examples use Flutter (flutter/packages#11830) 2026-06-04 stuartmorgan@google.com Sync analysis_options.yaml with flutter/flutter (flutter/packages#11823) 2026-06-04 stuartmorgan@google.com [path_provider] Create temp dir in tests if needed (flutter/packages#11841) 2026-06-04 jeff.ward@datadoghq.com [webview] Add new method for cross plugin webview access (flutter/packages#11714) 2026-06-04 47866232+chunhtai@users.noreply.github.com [ci] Renames the override post-release label for batch release (flutter/packages#11835) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
A new way of supporting cross plugin communication is coming in Flutter 3.44 which allows for access to plugin published values through the `FlutterPluginBinding` on Android and the `FlutterPluginRegistry` on iOS. Update native WebView access to support these new methods and deprecate the old methods. refs: flutter/flutter#121527 flutter/flutter#182753 ## Pre-Review Checklist
A new way of supporting cross plugin communication is coming in Flutter 3.44 which allows for access to plugin published values through the
FlutterPluginBindingon Android and theFlutterPluginRegistryon iOS. Update native WebView access to support these new methods and deprecate the old methods.refs: flutter/flutter#121527 flutter/flutter#182753
Pre-Review Checklist
[shared_preferences]///).