Skip to content

Commit 8495514

Browse files
committed
Exposes displayZoomControls, withOverviewMode and useWideViewPort settings for Android WebView
1 parent f3d169e commit 8495514

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ Future<Null> launch(String url, {
156156
bool supportMultipleWindows: false,
157157
bool appCacheEnabled: false,
158158
bool allowFileURLs: false,
159+
bool displayZoomControls: false,
160+
bool useWideViewPort: false,
161+
bool withOverviewMode: false,
159162
});
160163
```
161164

android/src/main/java/com/flutter_webview_plugin/FlutterWebviewPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
9393
boolean clearCache = call.argument("clearCache");
9494
boolean clearCookies = call.argument("clearCookies");
9595
boolean withZoom = call.argument("withZoom");
96+
boolean displayZoomControls = call.argument("displayZoomControls");
9697
boolean withLocalStorage = call.argument("withLocalStorage");
98+
boolean withOverviewMode = call.argument("withOverviewMode");
9799
boolean supportMultipleWindows = call.argument("supportMultipleWindows");
98100
boolean appCacheEnabled = call.argument("appCacheEnabled");
99101
Map<String, String> headers = call.argument("headers");
@@ -119,7 +121,9 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
119121
url,
120122
headers,
121123
withZoom,
124+
displayZoomControls,
122125
withLocalStorage,
126+
withOverviewMode,
123127
scrollBar,
124128
supportMultipleWindows,
125129
appCacheEnabled,

android/src/main/java/com/flutter_webview_plugin/WebviewManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ void openUrl(
339339
String url,
340340
Map<String, String> headers,
341341
boolean withZoom,
342+
boolean displayZoomControls,
342343
boolean withLocalStorage,
344+
boolean withOverviewMode,
343345
boolean scrollBar,
344346
boolean supportMultipleWindows,
345347
boolean appCacheEnabled,
@@ -351,7 +353,9 @@ void openUrl(
351353
webView.getSettings().setJavaScriptEnabled(withJavascript);
352354
webView.getSettings().setBuiltInZoomControls(withZoom);
353355
webView.getSettings().setSupportZoom(withZoom);
356+
webView.getSettings().setDisplayZoomControls(displayZoomControls);
354357
webView.getSettings().setDomStorageEnabled(withLocalStorage);
358+
webView.getSettings().setLoadWithOverviewMode(withOverviewMode);
355359
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(supportMultipleWindows);
356360

357361
webView.getSettings().setSupportMultipleWindows(supportMultipleWindows);

lib/src/base.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ class FlutterWebviewPlugin {
104104
/// - [invalidUrlRegex] is the regular expression of URLs that web view shouldn't load.
105105
/// For example, when webview is redirected to a specific URL, you want to intercept
106106
/// this process by stopping loading this URL and replacing webview by another screen.
107+
/// Android only settings:
108+
/// - [displayZoomControls]: display zoom controls on webview
109+
/// - [withOverviewMode]: enable overview mode for Android webview ( setLoadWithOverviewMode )
110+
/// - [useWideViewPort]: use wide viewport for Android webview ( setUseWideViewPort )
107111
Future<Null> launch(String url, {
108112
Map<String, String> headers,
109113
bool withJavascript,
@@ -114,8 +118,10 @@ class FlutterWebviewPlugin {
114118
Rect rect,
115119
String userAgent,
116120
bool withZoom,
121+
bool displayZoomControls,
117122
bool withLocalStorage,
118123
bool withLocalUrl,
124+
bool withOverviewMode,
119125
bool scrollBar,
120126
bool supportMultipleWindows,
121127
bool appCacheEnabled,
@@ -133,6 +139,7 @@ class FlutterWebviewPlugin {
133139
'enableAppScheme': enableAppScheme ?? true,
134140
'userAgent': userAgent,
135141
'withZoom': withZoom ?? false,
142+
'displayZoomControls': displayZoomControls ?? false,
136143
'withLocalStorage': withLocalStorage ?? true,
137144
'withLocalUrl': withLocalUrl ?? false,
138145
'scrollBar': scrollBar ?? true,
@@ -142,6 +149,7 @@ class FlutterWebviewPlugin {
142149
'useWideViewPort': useWideViewPort ?? false,
143150
'invalidUrlRegex': invalidUrlRegex,
144151
'geolocationEnabled': geolocationEnabled ?? false,
152+
'withOverviewMode': withOverviewMode ?? false,
145153
};
146154

147155
if (headers != null) {

lib/src/webview_scaffold.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ class WebviewScaffold extends StatefulWidget {
2222
this.persistentFooterButtons,
2323
this.bottomNavigationBar,
2424
this.withZoom,
25+
this.displayZoomControls,
2526
this.withLocalStorage,
2627
this.withLocalUrl,
28+
this.withOverviewMode,
29+
this.useWideViewPort,
2730
this.scrollBar,
2831
this.supportMultipleWindows,
2932
this.appCacheEnabled,
@@ -47,6 +50,7 @@ class WebviewScaffold extends StatefulWidget {
4750
final List<Widget> persistentFooterButtons;
4851
final Widget bottomNavigationBar;
4952
final bool withZoom;
53+
final bool displayZoomControls;
5054
final bool withLocalStorage;
5155
final bool withLocalUrl;
5256
final bool scrollBar;
@@ -58,6 +62,8 @@ class WebviewScaffold extends StatefulWidget {
5862
final bool resizeToAvoidBottomInset;
5963
final String invalidUrlRegex;
6064
final bool geolocationEnabled;
65+
final bool withOverviewMode;
66+
final bool useWideViewPort;
6167

6268
@override
6369
_WebviewScaffoldState createState() => _WebviewScaffoldState();
@@ -125,8 +131,11 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
125131
userAgent: widget.userAgent,
126132
rect: _rect,
127133
withZoom: widget.withZoom,
134+
displayZoomControls: widget.displayZoomControls,
128135
withLocalStorage: widget.withLocalStorage,
129136
withLocalUrl: widget.withLocalUrl,
137+
withOverviewMode: widget.withOverviewMode,
138+
useWideViewPort: widget.useWideViewPort,
130139
scrollBar: widget.scrollBar,
131140
supportMultipleWindows: widget.supportMultipleWindows,
132141
appCacheEnabled: widget.appCacheEnabled,

0 commit comments

Comments
 (0)