packages icon indicating copy to clipboard operation
packages copied to clipboard

[webview_flutter] Adds support to listen to url changes

Open bparrishMines opened this issue 1 year ago • 0 comments

Transfer of https://github.com/flutter/plugins/pull/7113 (All the comments of that PR have been addressed in this one)

This PR follows the procedure for changing federated plugins: https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#changing-federated-plugins

This is the aggregate solution for https://github.com/flutter/flutter/issues/27729 and is NOT intended to be submitted. This will be split into PRs for each package after approval of this PR.

This adds the PlatformNavigation.setOnUrlChange(UrlChange) method to track url changes.

Android adds support for this with the WebViewClient. doUpdateVisitedHistory

iOS adds support by observing the value WKWebView.URL. Since the WKWebView.URL would pass back an NSURL to the observeValue callback, the observeValue callback would need to distinguish the difference when returning an int or an identifier. So the ObjectOrIdentifier data class was created to handle this. Alternatives considered:

  • Convert NSURL to an NSString. This would work for this situation, but wouldn't work for a class that can't be easily converted to a String.
  • Create a separate observeValue callback method for returning an identifier. Potentially named observeIdentifier. This doesn't work for returning a list of Objects.

Pre-launch Checklist

  • [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
  • [x] I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • [x] I signed the CLA.
  • [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • [x] I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I added new tests to check the change I am making, or this PR is test-exempt.
  • [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

bparrishMines avatar Feb 27 '23 17:02 bparrishMines