diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java index b3986046..7da98f8a 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java @@ -10,12 +10,12 @@ import java.util.HashMap; import java.util.Map; public class WebResourceErrorExt { - private int errorCode; + private int type; @NonNull private String description; - public WebResourceErrorExt(int errorCode, @NonNull String description) { - this.errorCode = errorCode; + public WebResourceErrorExt(int type, @NonNull String description) { + this.type = type; this.description = description; } @@ -26,17 +26,17 @@ public class WebResourceErrorExt { public Map toMap() { Map webResourceErrorMap = new HashMap<>(); - webResourceErrorMap.put("errorCode", getErrorCode()); + webResourceErrorMap.put("type", getType()); webResourceErrorMap.put("description", getDescription()); return webResourceErrorMap; } - public int getErrorCode() { - return errorCode; + public int getType() { + return type; } - public void setErrorCode(int errorCode) { - this.errorCode = errorCode; + public void setType(int type) { + this.type = type; } @NonNull @@ -55,13 +55,13 @@ public class WebResourceErrorExt { WebResourceErrorExt that = (WebResourceErrorExt) o; - if (errorCode != that.errorCode) return false; + if (type != that.type) return false; return description.equals(that.description); } @Override public int hashCode() { - int result = errorCode; + int result = type; result = 31 * result + description.hashCode(); return result; } @@ -69,7 +69,7 @@ public class WebResourceErrorExt { @Override public String toString() { return "WebResourceErrorExt{" + - "errorCode=" + errorCode + + "type=" + type + ", description='" + description + '\'' + '}'; } diff --git a/dev_packages/generators/lib/src/exchangeable_object_generator.dart b/dev_packages/generators/lib/src/exchangeable_object_generator.dart index e6153a46..5c3197ef 100644 --- a/dev_packages/generators/lib/src/exchangeable_object_generator.dart +++ b/dev_packages/generators/lib/src/exchangeable_object_generator.dart @@ -519,6 +519,9 @@ class ExchangeableObjectGenerator } else { return value; } + } else if (elementType.isDartCoreMap) { + final genericTypes = Util.getGenericTypes(elementType); + return "$value${isNullable ? '?' : ''}.cast<${genericTypes.elementAt(0)}, ${genericTypes.elementAt(1)}>()"; } else if (fieldTypeElement != null && hasFromMapMethod(fieldTypeElement)) { final hasNullableFromMap = hasNullableFromMapFactory(fieldTypeElement); // remove class reference terminating with "_" diff --git a/example/integration_test/webview_flutter_test.dart b/example/integration_test/webview_flutter_test.dart index 239380c5..1b0e5a52 100644 --- a/example/integration_test/webview_flutter_test.dart +++ b/example/integration_test/webview_flutter_test.dart @@ -18,6 +18,15 @@ void main() { InAppWebViewController.setWebContentsDebuggingEnabled(true); } + WebView.debugLoggingSettings.usePrint = true; + WebView.debugLoggingSettings.maxLogMessageLength = -1; + InAppBrowser.debugLoggingSettings.usePrint = true; + InAppBrowser.debugLoggingSettings.maxLogMessageLength = -1; + ChromeSafariBrowser.debugLoggingSettings.usePrint = true; + ChromeSafariBrowser.debugLoggingSettings.maxLogMessageLength = -1; + WebAuthenticationSession.debugLoggingSettings.usePrint = true; + WebAuthenticationSession.debugLoggingSettings.maxLogMessageLength = -1; + in_app_webview_tests.main(); service_worker_controller_tests.main(); proxy_controller_tests.main(); diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 9e98dd5e..fae63896 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -3,12 +3,11 @@ export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart" +export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/.dart_tool/package_config.json" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/ios/Classes/InAppWebView/InAppWebView.swift b/ios/Classes/InAppWebView/InAppWebView.swift index fa2bf105..5425b20f 100755 --- a/ios/Classes/InAppWebView/InAppWebView.swift +++ b/ios/Classes/InAppWebView/InAppWebView.swift @@ -1818,7 +1818,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, } let webResourceRequest = WebResourceRequest(url: urlError, headers: nil) - let webResourceError = WebResourceError(errorCode: errorCode, errorDescription: errorDescription) + let webResourceError = WebResourceError(type: errorCode, errorDescription: errorDescription) channelDelegate?.onReceivedError(request: webResourceRequest, error: webResourceError) diff --git a/ios/Classes/Types/WebResourceError.swift b/ios/Classes/Types/WebResourceError.swift index 8f00e9c8..3183944b 100644 --- a/ios/Classes/Types/WebResourceError.swift +++ b/ios/Classes/Types/WebResourceError.swift @@ -8,17 +8,17 @@ import Foundation public class WebResourceError: NSObject { - var errorCode: Int + var type: Int var errorDescription: String - public init(errorCode: Int, errorDescription: String) { - self.errorCode = errorCode + public init(type: Int, errorDescription: String) { + self.type = type self.errorDescription = errorDescription } public func toMap () -> [String:Any?] { return [ - "errorCode": errorCode, + "type": type, "description": errorDescription ] } diff --git a/lib/src/android/proxy_controller.dart b/lib/src/android/proxy_controller.dart index 834adfa6..fb16ac1a 100644 --- a/lib/src/android/proxy_controller.dart +++ b/lib/src/android/proxy_controller.dart @@ -27,7 +27,14 @@ class ProxyController { } static ProxyController _init() { - _channel.setMethodCallHandler(_handleMethod); + _channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _instance = ProxyController(); return _instance!; } diff --git a/lib/src/android/service_worker_controller.dart b/lib/src/android/service_worker_controller.dart index 21cad6df..cbec5bb5 100644 --- a/lib/src/android/service_worker_controller.dart +++ b/lib/src/android/service_worker_controller.dart @@ -38,7 +38,14 @@ class ServiceWorkerController { } static ServiceWorkerController _init() { - _channel.setMethodCallHandler(_handleMethod); + _channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _instance = ServiceWorkerController(); return _instance!; } @@ -222,7 +229,14 @@ class AndroidServiceWorkerController { } static AndroidServiceWorkerController _init() { - _channel.setMethodCallHandler(_handleMethod); + _channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _instance = AndroidServiceWorkerController(); return _instance!; } diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/lib/src/chrome_safari_browser/chrome_safari_browser.dart index 2effd347..75afc38d 100755 --- a/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -62,7 +62,14 @@ class ChromeSafariBrowser { id = IdGenerator.generate(); this._channel = MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); - this._channel.setMethodCallHandler(_handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _isOpened = false; } @@ -83,7 +90,11 @@ class ChromeSafariBrowser { if (maxLogMessageLength >= 0 && message.length > maxLogMessageLength) { message = message.substring(0, maxLogMessageLength) + "..."; } - developer.log(message, name: this.runtimeType.toString()); + if (!ChromeSafariBrowser.debugLoggingSettings.usePrint) { + developer.log(message, name: this.runtimeType.toString()); + } else { + print("[${this.runtimeType.toString()}] $message"); + } } } diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 9faf1784..ac0be519 100755 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -42,7 +42,14 @@ class CookieManager { } static CookieManager _init() { - _channel.setMethodCallHandler(_handleMethod); + _channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _instance = CookieManager(); // ignore: deprecated_member_use_from_same_package _instance!.ios = IOSCookieManager.instance(); diff --git a/lib/src/debug_logging_settings.dart b/lib/src/debug_logging_settings.dart index f6d31ec0..554414d3 100644 --- a/lib/src/debug_logging_settings.dart +++ b/lib/src/debug_logging_settings.dart @@ -21,9 +21,13 @@ class DebugLoggingSettings { ///The default value is `-1`. int maxLogMessageLength; + ///Use [print] instead of `developer.log` to log messages. + bool usePrint; + DebugLoggingSettings({ this.enabled = kDebugMode, this.excludeFilter = const [], - this.maxLogMessageLength = -1 + this.maxLogMessageLength = -1, + this.usePrint = false }); } \ No newline at end of file diff --git a/lib/src/http_auth_credentials_database.dart b/lib/src/http_auth_credentials_database.dart index 366b46ac..2650eb53 100755 --- a/lib/src/http_auth_credentials_database.dart +++ b/lib/src/http_auth_credentials_database.dart @@ -23,7 +23,14 @@ class HttpAuthCredentialDatabase { } static HttpAuthCredentialDatabase _init() { - _channel.setMethodCallHandler(_handleMethod); + _channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _instance = HttpAuthCredentialDatabase(); return _instance!; } diff --git a/lib/src/in_app_browser/in_app_browser.dart b/lib/src/in_app_browser/in_app_browser.dart index b0cb5b57..81d48cf7 100755 --- a/lib/src/in_app_browser/in_app_browser.dart +++ b/lib/src/in_app_browser/in_app_browser.dart @@ -85,7 +85,14 @@ class InAppBrowser { id = IdGenerator.generate(); this._channel = MethodChannel('com.pichillilorenzo/flutter_inappbrowser_$id'); - this._channel.setMethodCallHandler(_handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _isOpened = false; webViewController = new InAppWebViewController.fromInAppBrowser( this._channel, this, this.initialUserScripts); @@ -108,7 +115,11 @@ class InAppBrowser { if (maxLogMessageLength >= 0 && message.length > maxLogMessageLength) { message = message.substring(0, maxLogMessageLength) + "..."; } - developer.log(message, name: this.runtimeType.toString()); + if (!InAppBrowser.debugLoggingSettings.usePrint) { + developer.log(message, name: this.runtimeType.toString()); + } else { + print("[${this.runtimeType.toString()}] $message"); + } } } diff --git a/lib/src/in_app_webview/headless_in_app_webview.dart b/lib/src/in_app_webview/headless_in_app_webview.dart index ca42523b..51bdb496 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -159,7 +159,14 @@ class HeadlessInAppWebView implements WebView, Disposable { webViewController = new InAppWebViewController(id, this); this._channel = MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview_$id'); - this._channel.setMethodCallHandler(handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } Future handleMethod(MethodCall call) async { diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index 3f3d0d6b..defde8f2 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -78,7 +78,14 @@ class InAppWebViewController { this._id = id; this._channel = MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id'); - this._channel.setMethodCallHandler(handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); this._webview = webview; this._userScripts = List.from(webview.initialUserScripts ?? []); @@ -123,7 +130,11 @@ class InAppWebViewController { if (maxLogMessageLength >= 0 && message.length > maxLogMessageLength) { message = message.substring(0, maxLogMessageLength) + "..."; } - developer.log(message, name: this.runtimeType.toString()); + if (!WebView.debugLoggingSettings.usePrint) { + developer.log(message, name: this.runtimeType.toString()); + } else { + print("[${this.runtimeType.toString()}] $message"); + } } } @@ -175,13 +186,13 @@ class InAppWebViewController { else if (isForMainFrame) { // ignore: deprecated_member_use_from_same_package _webview!.onLoadError!(this, request.url, - error.type.toNativeValue(), error.description); + error.type.toNativeValue() ?? -1, error.description); } } else { if (isForMainFrame) { _inAppBrowser! // ignore: deprecated_member_use_from_same_package - .onLoadError(request.url, error.type.toNativeValue(), + .onLoadError(request.url, error.type.toNativeValue() ?? -1, error.description); } _inAppBrowser!.onReceivedError(request, error); diff --git a/lib/src/platform_util.dart b/lib/src/platform_util.dart index b64da391..c93d9761 100644 --- a/lib/src/platform_util.dart +++ b/lib/src/platform_util.dart @@ -12,7 +12,14 @@ class PlatformUtil { } static PlatformUtil _init() { - _channel.setMethodCallHandler(_handleMethod); + _channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _instance = PlatformUtil(); return _instance!; } diff --git a/lib/src/print_job/print_job_controller.dart b/lib/src/print_job/print_job_controller.dart index 0363387a..77c932be 100644 --- a/lib/src/print_job/print_job_controller.dart +++ b/lib/src/print_job/print_job_controller.dart @@ -23,7 +23,14 @@ class PrintJobController implements Disposable { {required this.id}) { this._channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_printjobcontroller_$id'); - this._channel.setMethodCallHandler(_handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } Future _handleMethod(MethodCall call) async { diff --git a/lib/src/pull_to_refresh/pull_to_refresh_controller.dart b/lib/src/pull_to_refresh/pull_to_refresh_controller.dart index 64476f32..7aefb6b0 100644 --- a/lib/src/pull_to_refresh/pull_to_refresh_controller.dart +++ b/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -166,6 +166,13 @@ class PullToRefreshController { void initMethodChannel(dynamic id) { this._channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_$id'); - this._channel?.setMethodCallHandler(_handleMethod); + this._channel?.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } } diff --git a/lib/src/types/ajax_request.g.dart b/lib/src/types/ajax_request.g.dart index 6bc219c2..c76ed55c 100644 --- a/lib/src/types/ajax_request.g.dart +++ b/lib/src/types/ajax_request.g.dart @@ -119,7 +119,7 @@ class AjaxRequest { responseText: map['responseText'], responseXML: map['responseXML'], statusText: map['statusText'], - responseHeaders: map['responseHeaders'], + responseHeaders: map['responseHeaders']?.cast(), event: AjaxRequestEvent.fromMap(map['event']?.cast()), ); instance.action = AjaxRequestAction.fromNativeValue(map['action']); diff --git a/lib/src/types/fetch_request.g.dart b/lib/src/types/fetch_request.g.dart index a242803d..3c8f0406 100644 --- a/lib/src/types/fetch_request.g.dart +++ b/lib/src/types/fetch_request.g.dart @@ -69,7 +69,7 @@ class FetchRequest { final instance = FetchRequest( url: map['url'] != null ? Uri.parse(map['url']) : null, method: map['method'], - headers: map['headers'], + headers: map['headers']?.cast(), body: map['body'], mode: map['mode'], credentials: _fetchRequestCredentialDeserializer(map['credentials']), diff --git a/lib/src/types/print_job_duplex_mode.dart b/lib/src/types/print_job_duplex_mode.dart index 8568563f..08994d93 100644 --- a/lib/src/types/print_job_duplex_mode.dart +++ b/lib/src/types/print_job_duplex_mode.dart @@ -11,7 +11,7 @@ class PrintJobDuplexMode_ { // ignore: unused_field final String _value; // ignore: unused_field - final int _nativeValue = 0; + final int? _nativeValue = null; const PrintJobDuplexMode_._internal(this._value); diff --git a/lib/src/types/print_job_duplex_mode.g.dart b/lib/src/types/print_job_duplex_mode.g.dart index 20956003..043899a5 100644 --- a/lib/src/types/print_job_duplex_mode.g.dart +++ b/lib/src/types/print_job_duplex_mode.g.dart @@ -9,7 +9,7 @@ part of 'print_job_duplex_mode.dart'; ///Class representing the orientation of a [PrintJobController]. class PrintJobDuplexMode { final String _value; - final int _nativeValue; + final int? _nativeValue; const PrintJobDuplexMode._internal(this._value, this._nativeValue); // ignore: unused_element factory PrintJobDuplexMode._internalMultiPlatform( @@ -107,8 +107,8 @@ class PrintJobDuplexMode { ///Gets [String] value. String toValue() => _value; - ///Gets [int] native value. - int toNativeValue() => _nativeValue; + ///Gets [int?] native value. + int? toNativeValue() => _nativeValue; @override int get hashCode => _value.hashCode; diff --git a/lib/src/types/ssl_error_type.dart b/lib/src/types/ssl_error_type.dart index 52c1836f..83603717 100644 --- a/lib/src/types/ssl_error_type.dart +++ b/lib/src/types/ssl_error_type.dart @@ -13,7 +13,7 @@ class SslErrorType_ { // ignore: unused_field final String _value; // ignore: unused_field - final int _nativeValue = -1; + final int? _nativeValue = null; const SslErrorType_._internal(this._value); ///The certificate is not yet valid. diff --git a/lib/src/types/ssl_error_type.g.dart b/lib/src/types/ssl_error_type.g.dart index 47d34e7c..ab12ddf4 100644 --- a/lib/src/types/ssl_error_type.g.dart +++ b/lib/src/types/ssl_error_type.g.dart @@ -10,7 +10,7 @@ part of 'ssl_error_type.dart'; ///Used by the [ServerTrustChallenge] class. class SslErrorType { final String _value; - final int _nativeValue; + final int? _nativeValue; const SslErrorType._internal(this._value, this._nativeValue); // ignore: unused_element factory SslErrorType._internalMultiPlatform( @@ -253,8 +253,8 @@ class SslErrorType { ///Gets [String] value. String toValue() => _value; - ///Gets [int] native value. - int toNativeValue() => _nativeValue; + ///Gets [int?] native value. + int? toNativeValue() => _nativeValue; @override int get hashCode => _value.hashCode; diff --git a/lib/src/types/url_request.g.dart b/lib/src/types/url_request.g.dart index 703fe706..e8548b48 100644 --- a/lib/src/types/url_request.g.dart +++ b/lib/src/types/url_request.g.dart @@ -189,7 +189,7 @@ class URLRequest { url: map['url'] != null ? Uri.parse(map['url']) : null, method: map['method'], body: map['body'], - headers: map['headers'], + headers: map['headers']?.cast(), iosAllowsCellularAccess: map['allowsCellularAccess'], allowsCellularAccess: map['allowsCellularAccess'], iosAllowsConstrainedNetworkAccess: map['allowsConstrainedNetworkAccess'], diff --git a/lib/src/types/url_response.dart b/lib/src/types/url_response.dart index 5e918c4f..be768b24 100644 --- a/lib/src/types/url_response.dart +++ b/lib/src/types/url_response.dart @@ -2,10 +2,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_i part 'url_response.g.dart'; -Map? _headersDeserializer(dynamic value) { - return value?.cast(); -} - ///The metadata associated with the response to a URL load request, independent of protocol and URL scheme. @ExchangeableObject() class URLResponse_ { @@ -25,7 +21,6 @@ class URLResponse_ { String? textEncodingName; ///All HTTP header fields of the response. - @ExchangeableObjectProperty(deserializer: _headersDeserializer) Map? headers; ///The response’s HTTP status code. @@ -61,7 +56,6 @@ class IOSURLResponse_ { String? textEncodingName; ///All HTTP header fields of the response. - @ExchangeableObjectProperty(deserializer: _headersDeserializer) Map? headers; ///The response’s HTTP status code. diff --git a/lib/src/types/url_response.g.dart b/lib/src/types/url_response.g.dart index b42d383b..57f4bf8b 100644 --- a/lib/src/types/url_response.g.dart +++ b/lib/src/types/url_response.g.dart @@ -48,7 +48,7 @@ class URLResponse { mimeType: map['mimeType'], suggestedFilename: map['suggestedFilename'], textEncodingName: map['textEncodingName'], - headers: _headersDeserializer(map['headers']), + headers: map['headers']?.cast(), statusCode: map['statusCode'], ); return instance; @@ -121,7 +121,7 @@ class IOSURLResponse { mimeType: map['mimeType'], suggestedFilename: map['suggestedFilename'], textEncodingName: map['textEncodingName'], - headers: _headersDeserializer(map['headers']), + headers: map['headers']?.cast(), statusCode: map['statusCode'], ); return instance; diff --git a/lib/src/types/web_resource_error_type.dart b/lib/src/types/web_resource_error_type.dart index acce3de5..25a2f1ef 100644 --- a/lib/src/types/web_resource_error_type.dart +++ b/lib/src/types/web_resource_error_type.dart @@ -9,7 +9,7 @@ class WebResourceErrorType_ { // ignore: unused_field final String _value; // ignore: unused_field - final int _nativeValue = 0; + final int? _nativeValue = null; const WebResourceErrorType_._internal(this._value); diff --git a/lib/src/types/web_resource_error_type.g.dart b/lib/src/types/web_resource_error_type.g.dart index 2c5beaa2..587c03f1 100644 --- a/lib/src/types/web_resource_error_type.g.dart +++ b/lib/src/types/web_resource_error_type.g.dart @@ -9,7 +9,7 @@ part of 'web_resource_error_type.dart'; ///Class that represents the error types returned by URL loading APIs. class WebResourceErrorType { final String _value; - final int _nativeValue; + final int? _nativeValue; const WebResourceErrorType._internal(this._value, this._nativeValue); // ignore: unused_element factory WebResourceErrorType._internalMultiPlatform( @@ -1005,8 +1005,8 @@ class WebResourceErrorType { ///Gets [String] value. String toValue() => _value; - ///Gets [int] native value. - int toNativeValue() => _nativeValue; + ///Gets [int?] native value. + int? toNativeValue() => _nativeValue; @override int get hashCode => _value.hashCode; diff --git a/lib/src/types/web_resource_request.g.dart b/lib/src/types/web_resource_request.g.dart index 9e0e0b32..3255ebc7 100644 --- a/lib/src/types/web_resource_request.g.dart +++ b/lib/src/types/web_resource_request.g.dart @@ -53,7 +53,7 @@ class WebResourceRequest { } final instance = WebResourceRequest( url: Uri.parse(map['url']), - headers: map['headers'], + headers: map['headers']?.cast(), method: map['method'], hasGesture: map['hasGesture'], isForMainFrame: map['isForMainFrame'], diff --git a/lib/src/types/web_resource_response.g.dart b/lib/src/types/web_resource_response.g.dart index c8861dea..8a705351 100644 --- a/lib/src/types/web_resource_response.g.dart +++ b/lib/src/types/web_resource_response.g.dart @@ -48,7 +48,7 @@ class WebResourceResponse { } final instance = WebResourceResponse( data: map['data'], - headers: map['headers'], + headers: map['headers']?.cast(), statusCode: map['statusCode'], reasonPhrase: map['reasonPhrase'], ); diff --git a/lib/src/web/headless_in_app_web_view_web_element.dart b/lib/src/web/headless_in_app_web_view_web_element.dart index 46e75195..44bb8c26 100644 --- a/lib/src/web/headless_in_app_web_view_web_element.dart +++ b/lib/src/web/headless_in_app_web_view_web_element.dart @@ -24,7 +24,14 @@ class HeadlessInAppWebViewWebElement implements Disposable { _messenger, ); - this._channel?.setMethodCallHandler(handleMethodCall); + this._channel?.setMethodCallHandler((call) async { + try { + return await handleMethodCall(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } Future handleMethodCall(MethodCall call) async { diff --git a/lib/src/web/headless_inappwebview_manager.dart b/lib/src/web/headless_inappwebview_manager.dart index 6c0d80bb..bb373ec2 100644 --- a/lib/src/web/headless_inappwebview_manager.dart +++ b/lib/src/web/headless_inappwebview_manager.dart @@ -20,8 +20,14 @@ class HeadlessInAppWebViewManager { const StandardMethodCodec(), _messenger, ); - HeadlessInAppWebViewManager._sharedChannel - .setMethodCallHandler(handleMethod); + HeadlessInAppWebViewManager._sharedChannel.setMethodCallHandler((call) async { + try { + return await handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } Future handleMethod(MethodCall call) async { diff --git a/lib/src/web/in_app_web_view_web_element.dart b/lib/src/web/in_app_web_view_web_element.dart index 0cddc5f2..3bcc5758 100644 --- a/lib/src/web/in_app_web_view_web_element.dart +++ b/lib/src/web/in_app_web_view_web_element.dart @@ -40,7 +40,14 @@ class InAppWebViewWebElement implements Disposable { _messenger, ); - this._channel?.setMethodCallHandler(handleMethodCall); + this._channel?.setMethodCallHandler((call) async { + try { + return await handleMethodCall(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); bridgeJsObject = js.JsObject.fromBrowserObject( js.context[WebPlatformManager.BRIDGE_JS_OBJECT_NAME]); diff --git a/lib/src/web/platform_util.dart b/lib/src/web/platform_util.dart index c7eeb8ba..96e64eb1 100644 --- a/lib/src/web/platform_util.dart +++ b/lib/src/web/platform_util.dart @@ -19,7 +19,14 @@ class PlatformUtil implements Disposable { _messenger, ); - this._channel?.setMethodCallHandler(handleMethodCall); + this._channel?.setMethodCallHandler((call) async { + try { + return await handleMethodCall(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } Future handleMethodCall(MethodCall call) async { diff --git a/lib/src/web_authentication_session/web_authenticate_session.dart b/lib/src/web_authentication_session/web_authenticate_session.dart index a7a7a84c..96142893 100755 --- a/lib/src/web_authentication_session/web_authenticate_session.dart +++ b/lib/src/web_authentication_session/web_authenticate_session.dart @@ -95,7 +95,14 @@ class WebAuthenticationSession implements Disposable { initialSettings ?? WebAuthenticationSessionSettings(); this._channel = MethodChannel( 'com.pichillilorenzo/flutter_webauthenticationsession_$id'); - this._channel.setMethodCallHandler(_handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } _debugLog(String method, dynamic args) { @@ -115,7 +122,11 @@ class WebAuthenticationSession implements Disposable { if (maxLogMessageLength >= 0 && message.length > maxLogMessageLength) { message = message.substring(0, maxLogMessageLength) + "..."; } - developer.log(message, name: this.runtimeType.toString()); + if (!WebAuthenticationSession.debugLoggingSettings.usePrint) { + developer.log(message, name: this.runtimeType.toString()); + } else { + print("[${this.runtimeType.toString()}] $message"); + } } } diff --git a/lib/src/web_message/web_message_channel.dart b/lib/src/web_message/web_message_channel.dart index d9e5d6a4..4813a865 100644 --- a/lib/src/web_message/web_message_channel.dart +++ b/lib/src/web_message/web_message_channel.dart @@ -19,7 +19,14 @@ class WebMessageChannel { {required this.id, required this.port1, required this.port2}) { this._channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_web_message_channel_$id'); - this._channel.setMethodCallHandler(_handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } static WebMessageChannel? fromMap(Map? map) { diff --git a/lib/src/web_message/web_message_listener.dart b/lib/src/web_message/web_message_listener.dart index 9bb2cff8..d1b0c9f3 100644 --- a/lib/src/web_message/web_message_listener.dart +++ b/lib/src/web_message/web_message_listener.dart @@ -36,7 +36,14 @@ class WebMessageListener { "allowedOriginRules cannot contain empty strings"); this._channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_web_message_listener_$jsObjectName'); - this._channel.setMethodCallHandler(_handleMethod); + this._channel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); } Future _handleMethod(MethodCall call) async { diff --git a/lib/src/web_storage/web_storage_manager.dart b/lib/src/web_storage/web_storage_manager.dart index 65b17277..0710bf03 100755 --- a/lib/src/web_storage/web_storage_manager.dart +++ b/lib/src/web_storage/web_storage_manager.dart @@ -31,7 +31,14 @@ class WebStorageManager { } static WebStorageManager _init() { - _staticChannel.setMethodCallHandler(_handleMethod); + _staticChannel.setMethodCallHandler((call) async { + try { + return await _handleMethod(call); + } on Error catch (e) { + print(e); + print(e.stackTrace); + } + }); _instance = new WebStorageManager(); return _instance!; }