Skip to content

feat: Expose setUseWideViewPort on Android (#106999) #9151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Gustl22
Copy link
Contributor

@Gustl22 Gustl22 commented Apr 25, 2025

The option to set whether the webview should use the wide viewport should be available.
Also the default is changed to false, because this is the expected behavior on Android devices:
https://developer.android.com/develop/ui/views/layout/webapps/targeting
On iOS also the default behavior is to NOT use wide viewport, so this is aligned.

Note: When your page is rendered in a WebView, it doesn't use wide viewport mode by default. You can enable wide viewport mode with setUseWideViewPort().

This also partically solves flutter/flutter#106999, as then the correct height is returned from document.documentElement.scrollHeight; property.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

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

@Gustl22 Gustl22 requested a review from bparrishMines as a code owner April 25, 2025 14:08
@Gustl22 Gustl22 changed the title 106999 webview expose wide screen feat: Expose setUseWideViewPort on Android (#106999) Apr 25, 2025
@stuartmorgan-g
Copy link
Contributor

Also the default is changed to false, because this is the expected behavior on Android devices

This may break some people; see flutter/flutter#93125 for example.

@Gustl22
Copy link
Contributor Author

Gustl22 commented Apr 30, 2025

Thank you for the intels.

This may break some people; see flutter/flutter#93125 for example.

That's true, what exactly should be the next steps? I also tried to reproduce your linked issue, but couldn't as the linked site was reworked and doesn't show this problem any more.

  1. Use true as default for setUseWideViewPort
  • would ensure that nothing breaks due to keeping the current default
  • may leads to annoyance as package users expect the same behavior on Android and iOS
  1. Use false as default for setUseWideViewPort
  • Making a breaking change and write a migration guide
  • probably very few care as the behavior was different on Android and iOS and noone noticed
  • Nontheless could lead to unexpected outcome for certain products, when using flutter specifically on only one platform
  • WebViews are hard to test so the behavior should be aligned in both platforms to not challenge more differences across both platforms
  • Raise a major version for webview package
  • Aligns with native Android and Flutter iOS implementation
Webkit / iOS Android setUseWideViewPort(true) Android setUseWideViewPort(false)

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.

2 participants