added static WebView.debugLogging

This commit is contained in:
Lorenzo Pichilli 2022-04-26 12:16:47 +02:00
parent 8d1bfc1f4b
commit 3087bbbc0e
3 changed files with 23 additions and 1 deletions

View File

@ -493,7 +493,8 @@ class InAppBrowser {
///[InAppWebViewSettings.enableViewportScale], [InAppWebViewSettings.allowsAirPlayForMediaPlayback],
///[InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled],
///[InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity],
///[InAppWebViewSettings.ignoresViewportScaleLimits],
///[InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains],
///[InAppWebViewSettings.upgradeKnownHostsToHTTPS],
///will have no effect due to a `WKWebView` limitation when creating a new window WebView: it's impossible to return a new `WKWebView`
///with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview).
///So, these options will be inherited from the caller WebView.

View File

@ -3,6 +3,7 @@ import 'dart:collection';
import 'dart:typed_data';
import 'dart:convert';
import 'dart:core';
import 'dart:developer' as developer;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -105,6 +106,14 @@ class InAppWebViewController
}
Future<dynamic> handleMethod(MethodCall call) async {
if (WebView.debugLogging && (call.method.startsWith("on") || call.method.startsWith("should")) &&
call.method != "onCallJsHandler") {
developer.log(
call.method.toString() + ": using " + call.arguments.toString(),
name: this.runtimeType.toString());
}
switch (call.method) {
case "onLoadStart":
_injectedScriptsFromURL.clear();
@ -951,7 +960,9 @@ class InAppWebViewController
ContextMenuItem menuItemClicked = ContextMenuItem(
id: id,
// ignore: deprecated_member_use_from_same_package
androidId: androidId,
// ignore: deprecated_member_use_from_same_package
iosId: iosId,
title: title,
action: null);
@ -1021,6 +1032,12 @@ class InAppWebViewController
// decode args to json
List<dynamic> args = jsonDecode(call.arguments["args"]);
if (WebView.debugLogging && (handlerName.startsWith("on") || handlerName.startsWith("should"))) {
developer.log(
handlerName.toString() + ": using " + args.toString(),
name: this.runtimeType.toString());
}
switch (handlerName) {
case "onLoadResource":
if ((_webview != null && _webview!.onLoadResource != null) ||

View File

@ -12,6 +12,9 @@ import 'headless_in_app_webview.dart';
///Abstract class that represents a WebView. Used by [InAppWebView] and [HeadlessInAppWebView].
abstract class WebView {
///Enables WebView debug logging info. Logging is on by default.
static bool debugLogging = true;
///The window id of a [CreateWindowAction.windowId].
final int? windowId;
@ -187,6 +190,7 @@ abstract class WebView {
///[InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled],
///[InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity],
///[InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains],
///[InAppWebViewSettings.upgradeKnownHostsToHTTPS],
///will have no effect due to a `WKWebView` limitation when creating the new window WebView: it's impossible to return the new `WKWebView`
///with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview).
///So, these options will be inherited from the caller WebView.