Skip to content

Commit 760d6bd

Browse files
authored
Merge pull request #453 from Srynetix/debug-integration
Allow web contents debugging in Chrome
2 parents 6aca2b2 + 3c9bbe1 commit 760d6bd

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
102102
boolean useWideViewPort = call.argument("useWideViewPort");
103103
String invalidUrlRegex = call.argument("invalidUrlRegex");
104104
boolean geolocationEnabled = call.argument("geolocationEnabled");
105+
boolean debuggingEnabled = call.argument("debuggingEnabled");
105106

106107
if (webViewManager == null || webViewManager.closed == true) {
107108
webViewManager = new WebviewManager(activity, context);
@@ -126,7 +127,8 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
126127
allowFileURLs,
127128
useWideViewPort,
128129
invalidUrlRegex,
129-
geolocationEnabled
130+
geolocationEnabled,
131+
debuggingEnabled
130132
);
131133
result.success(null);
132134
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ void openUrl(
346346
boolean allowFileURLs,
347347
boolean useWideViewPort,
348348
String invalidUrlRegex,
349-
boolean geolocationEnabled
349+
boolean geolocationEnabled,
350+
boolean debuggingEnabled
350351
) {
351352
webView.getSettings().setJavaScriptEnabled(withJavascript);
352353
webView.getSettings().setBuiltInZoomControls(withZoom);
@@ -362,7 +363,10 @@ void openUrl(
362363
webView.getSettings().setAllowUniversalAccessFromFileURLs(allowFileURLs);
363364

364365
webView.getSettings().setUseWideViewPort(useWideViewPort);
365-
366+
367+
// Handle debugging
368+
webView.setWebContentsDebuggingEnabled(debuggingEnabled);
369+
366370
webViewClient.updateInvalidUrlRegex(invalidUrlRegex);
367371

368372
if (geolocationEnabled) {

lib/src/base.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class FlutterWebviewPlugin {
130130
bool useWideViewPort,
131131
String invalidUrlRegex,
132132
bool geolocationEnabled,
133+
bool debuggingEnabled,
133134
}) async {
134135
final args = <String, dynamic>{
135136
'url': url,
@@ -149,6 +150,7 @@ class FlutterWebviewPlugin {
149150
'useWideViewPort': useWideViewPort ?? false,
150151
'invalidUrlRegex': invalidUrlRegex,
151152
'geolocationEnabled': geolocationEnabled ?? false,
153+
'debuggingEnabled': debuggingEnabled ?? false,
152154
};
153155

154156
if (headers != null) {

lib/src/webview_scaffold.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class WebviewScaffold extends StatefulWidget {
3232
this.allowFileURLs,
3333
this.resizeToAvoidBottomInset = false,
3434
this.invalidUrlRegex,
35-
this.geolocationEnabled
35+
this.geolocationEnabled,
36+
this.debuggingEnabled = false,
3637
}) : super(key: key);
3738

3839
final PreferredSizeWidget appBar;
@@ -58,6 +59,7 @@ class WebviewScaffold extends StatefulWidget {
5859
final bool resizeToAvoidBottomInset;
5960
final String invalidUrlRegex;
6061
final bool geolocationEnabled;
62+
final bool debuggingEnabled;
6163

6264
@override
6365
_WebviewScaffoldState createState() => _WebviewScaffoldState();
@@ -153,7 +155,8 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
153155
appCacheEnabled: widget.appCacheEnabled,
154156
allowFileURLs: widget.allowFileURLs,
155157
invalidUrlRegex: widget.invalidUrlRegex,
156-
geolocationEnabled: widget.geolocationEnabled
158+
geolocationEnabled: widget.geolocationEnabled,
159+
debuggingEnabled: widget.debuggingEnabled,
157160
);
158161
} else {
159162
if (_rect != value) {

0 commit comments

Comments
 (0)