-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[webview_flutter] Adds support to listen to url changes #7113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some small nits! Feel free to start breaking out the sub PRs and we can start getting it landed.
packages/webview_flutter/webview_flutter/example/integration_test/webview_flutter_test.dart
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md
Show resolved
Hide resolved
...bview_flutter/webview_flutter_platform_interface/test/platform_navigation_delegate_test.dart
Show resolved
Hide resolved
...webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.mocks.dart
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFURLHostApi.h
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFURLHostApi.h
Show resolved
Hide resolved
instanceManager: _nsUrlHostApi.instanceManager, | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not something that needs action, but to file for reference as we evaluate this approach: I think NSURL
is a good example of a place where hewing as close as possible to the native APIs is actually more trouble than it's worth (until/unless we have auto-generated language projections). It's essentially just a string with utility methods, and we have very similar functionality in Dart already in the form of Uri
. In practice, if we passed strings over the channel instead of objects, and converted them to NSURL
and Uri
on the respective language sides, it would be simpler since it would eliminate object tracking for URLs, and work just as well in almost all cases. (The only example I can think of where it wouldn't would be things that can be expressed as NSURL
s but not Uri
s, but that's very rare.)
packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFURLTests.m
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart
Show resolved
Hide resolved
We've just completed the migration of the plugin code to the flutter/packages repository, as described in https://flutter.dev/go/flutter-plugins-repo-migration, and this repository is now being archived. Unfortunately that means that all in-progress PRs here must be moved to flutter/packages. Please see our instructions for an explanation of how to move your PR, and if you have any issues moving your PR please don't hesitate to reach out in the #hackers-ecosystem channel in Discord. Our apologies that your PR was caught in this one-time transition. We're aware that it's disruptive in the short term, and appreciate your help in getting us to a better long-term state! |
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 flutter/flutter#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, theobserveValue
callback would need to distinguish the difference when returning anint
or an identifier. So theObjectOrIdentifier
data class was created to handle this. Alternatives considered:NSURL
to anNSString
. This would work for this situation, but wouldn't work for a class that can't be easily converted to aString
.observeValue
callback method for returning an identifier. Potentially namedobserveIdentifier
. This doesn't work for returning a list of Objects.Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.