Skip to content

[webview] Add new method for cross plugin webview access#11714

Open
fuzzybinary wants to merge 6 commits into
flutter:mainfrom
fuzzybinary:webview-new-publish-api
Open

[webview] Add new method for cross plugin webview access#11714
fuzzybinary wants to merge 6 commits into
flutter:mainfrom
fuzzybinary:webview-new-publish-api

Conversation

@fuzzybinary
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md Outdated
Comment thread packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml Outdated
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
@fuzzybinary fuzzybinary force-pushed the webview-new-publish-api branch from 796dc17 to c4d49c6 Compare May 14, 2026 20:21
@bparrishMines bparrishMines added the CICD Run CI/CD label May 20, 2026
environment:
sdk: ^3.10.0
flutter: ">=3.38.0"
flutter: ">=3.44.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything from here on can be extracted to a private helper instead of duplicated.

version: 4.13.0

environment:
sdk: ^3.9.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We require that the Dart and Flutter versions align in our packages, so this needs to be updated as well.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

We've rolled 3.44 stable into the repo, and master has been fixed upstream to report 3.45.0-*, so if you merge in main when addressing my comments, CI should pass.

# Conflicts:
#	packages/webview_flutter/webview_flutter_android/CHANGELOG.md
#	packages/webview_flutter/webview_flutter_android/pubspec.yaml
@github-actions github-actions Bot removed the CICD Run CI/CD label May 21, 2026
@fuzzybinary
Copy link
Copy Markdown
Contributor Author

😬 When updating this it looks like there's a secondary problem. While valuePublished(byPlugin:) was added to FlutterPluginRegistrar on iOS, I didn't add it on macOS, and the WKWebView plugin is "Darwin" code, meaning its meant to run on both macOS and iOS. I don't know how it slipped through my initial testing but maybe something changed?

Thoughts on the correct solution here? I can go in and add the valuePublishedByPlugin method on the macOS FlutterPluginRegistrar, but that would mean trying to get that into a patch release of 3.44,

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 CHANGELOG changes for Android. Can I have both ## NEXT for the next patch bump and a header for the next minor bump, or should I have combined them?

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

I could mark the external method as iOS only for time being, then add the required method to macOS later...

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.

Also question about the CHANGELOG changes for Android. Can I have both ## NEXT for the next patch bump and a header for the next minor bump, or should I have combined them?

They need to be combined.

Copy link
Copy Markdown
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label May 22, 2026
@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

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).

@github-actions github-actions Bot removed the CICD Run CI/CD label May 27, 2026
@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label May 27, 2026
@fuzzybinary
Copy link
Copy Markdown
Contributor Author

Linux repo_checks is complaining about format changes but I'm not seeing any changes when I run the formatter. Is CICD using a different version?

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Are you on a very recent master? There's apparently a formatter behavior change that's not target-SDK-version gated like most Dart formatter changes have been, and it hasn't rolled into this repo yet, so you may be getting a different local format.

To make sure you match, you can temporarily sync your local Flutter to this version and then format.)

@github-actions github-actions Bot removed the CICD Run CI/CD label May 28, 2026
@fuzzybinary
Copy link
Copy Markdown
Contributor Author

I was actually on Flutter Stable (3.44). Syncing to that commit and reformatting did make some changes, so hopefully it's now correct.

@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label May 28, 2026
Copy link
Copy Markdown
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label May 28, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 28, 2026
@auto-submit
Copy link
Copy Markdown
Contributor

auto-submit Bot commented May 28, 2026

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.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Oops, I thought @bparrishMines had already approved this.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants