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 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.5.0

* Adds support to set using wide view port. See `AndroidWebViewController.setUseWideViewPort`.

## 4.4.2

* Updates pigeon generated code to fix `ImplicitSamInstance` and `SyntheticAccessor` Kotlin lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AndroidWebViewController extends PlatformWebViewController {
_webView.settings.setJavaScriptCanOpenWindowsAutomatically(true);
_webView.settings.setSupportMultipleWindows(true);
_webView.settings.setLoadWithOverviewMode(true);
_webView.settings.setUseWideViewPort(true);
_webView.settings.setUseWideViewPort(false);
_webView.settings.setDisplayZoomControls(false);
_webView.settings.setBuiltInZoomControls(true);

Expand Down Expand Up @@ -599,6 +599,13 @@ class AndroidWebViewController extends PlatformWebViewController {
Future<void> setTextZoom(int textZoom) =>
_webView.settings.setTextZoom(textZoom);

/// Sets whether the WebView should enable support for the "viewport" HTML
/// meta tag or should use a wide viewport.
///
/// The default is false.
Future<void> setUseWideViewPort(bool use) =>
_webView.settings.setUseWideViewPort(use);

/// Enables or disables content URL access.
///
/// The default is true.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_android
description: A Flutter plugin that provides a WebView widget on Android.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 4.4.2
version: 4.5.0

environment:
sdk: ^3.6.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void main() {
.called(1);
verify(mockWebSettings.setLoadWithOverviewMode(true)).called(1);
verify(mockWebSettings.setSupportMultipleWindows(true)).called(1);
verify(mockWebSettings.setUseWideViewPort(true)).called(1);
verify(mockWebSettings.setUseWideViewPort(false)).called(1);
});

test('loadFile without file prefix', () async {
Expand Down Expand Up @@ -1576,6 +1576,22 @@ void main() {
verify(mockSettings.setMediaPlaybackRequiresUserGesture(true)).called(1);
});

test('setUseWideViewPort', () async {
final MockWebView mockWebView = MockWebView();
final MockWebSettings mockSettings = MockWebSettings();
final AndroidWebViewController controller = createControllerWithMocks(
mockWebView: mockWebView,
mockSettings: mockSettings,
);

clearInteractions(mockWebView);

await controller.setUseWideViewPort(true);

verify(mockWebView.settings).called(1);
verify(mockSettings.setUseWideViewPort(true)).called(1);
});

test('setAllowContentAccess', () async {
final MockWebView mockWebView = MockWebView();
final MockWebSettings mockSettings = MockWebSettings();
Expand Down