[webview_flutter_wkwebview] skip other navigation requests on iOS #5082
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In flutters webview package you can set a navigation delegate which is triggered when the user clicks on a link in the webview. This can be used to load these pages in an in-app browser or external browser for example but I can imagine it has other use-cases as well.
On Android this seems to work well but on iOS the delegate is triggered onload without any user action involved. It seems like this is an implementation issue. Currently, we the
decidePolicyForNavigationAction
handler is used to trigger the navigation delegate in flutter. This is fine but it seems like this handler is more generic on iOS and is also triggered whenever an URL is loaded. The fix has been discussed already:See: flutter/flutter#73242 (comment)
Now that flutter/plugins#6863 has added support for
WKNavigationAction.navigationType
we can actually solve this issue by excludingother
navigation types. This is what this PR does, it excludes theother
navigation type so that both Android and iOS behave similarly.Issue: flutter/flutter#73242
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.