From b66eeae75af12df2f833df6072f97ad4292d74a4 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 27 Nov 2023 09:59:06 +0100 Subject: [PATCH] removed util platform check --- .../src/in_app_webview/in_app_webview.dart | 11 +-- .../in_app_webview_controller.dart | 2 +- .../chrome_safari_browser.dart | 8 +- .../lib/src/cookie_manager.dart | 11 +-- .../src/in_app_webview/in_app_webview.dart | 11 +-- .../web_authenticate_session.dart | 6 +- .../lib/src/cookie_manager.dart | 11 +-- .../src/in_app_browser/in_app_browser.dart | 4 +- .../headless_in_app_webview.dart | 12 +-- .../src/in_app_webview/in_app_webview.dart | 93 +++++++++---------- .../lib/src/inappwebview_platform.dart | 21 +++-- .../web_authenticate_session.dart | 6 +- .../src/web_message/web_message_channel.dart | 10 +- .../src/web_message/web_message_listener.dart | 10 +- .../src/platform_webview_asset_loader.dart | 15 ++- 15 files changed, 103 insertions(+), 128 deletions(-) diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart index 8a6b711d..6243921a 100755 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart @@ -262,16 +262,11 @@ class AndroidInAppWebViewWidgetCreationParams final AndroidPullToRefreshController? pullToRefreshController; } -///{@template flutter_inappwebview.InAppWebView} -///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- Web -///{@endtemplate} +///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget} class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget { /// Constructs a [AndroidInAppWebViewWidget]. + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget} AndroidInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params) : super.implementation( params is AndroidInAppWebViewWidgetCreationParams diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index e374d991..deb5e076 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2455,7 +2455,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController @override Future removeUserScripts( {required List userScripts}) async { - for (final userScript in userScripts) { + for (final userScript in userScripts) { await removeUserScript(userScript: userScript); } } diff --git a/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart index dd837cd9..c377ec0e 100755 --- a/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -125,11 +125,9 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser assert(!_isOpened, 'The browser is already opened.'); _isOpened = true; - if (Util.isIOS) { - assert(url != null, 'The specified URL must not be null on iOS.'); - assert(['http', 'https'].contains(url!.scheme), - 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); - } + assert(url != null, 'The specified URL must not be null on iOS.'); + assert(['http', 'https'].contains(url!.scheme), + 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); if (url != null) { assert(url.toString().isNotEmpty, 'The specified URL must not be empty.'); } diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index e328c040..70d016d2 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -418,14 +418,9 @@ class IOSCookieManager extends PlatformCookieManager } Future _shouldUseJavascript() async { - if (Util.isIOS || Util.isMacOS) { - final platformUtil = PlatformUtil.instance(); - final systemVersion = await platformUtil.getSystemVersion(); - return Util.isIOS - ? systemVersion.compareTo("11") == -1 - : systemVersion.compareTo("10.13") == -1; - } - return false; + final platformUtil = PlatformUtil.instance(); + final systemVersion = await platformUtil.getSystemVersion(); + return systemVersion.compareTo("10.13") == -1; } @override diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart index d86ce979..4deaefd9 100755 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart @@ -260,16 +260,11 @@ class IOSInAppWebViewWidgetCreationParams final IOSPullToRefreshController? pullToRefreshController; } -///{@template flutter_inappwebview.InAppWebView} -///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree. -/// -///**Supported Platforms/Implementations**: -///- IOS native WebView -///- iOS -///- Web -///{@endtemplate} +///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget} class IOSInAppWebViewWidget extends PlatformInAppWebViewWidget { /// Constructs a [IOSInAppWebViewWidget]. + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget} IOSInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params) : super.implementation( params is IOSInAppWebViewWidgetCreationParams diff --git a/flutter_inappwebview_ios/lib/src/web_authentication_session/web_authenticate_session.dart b/flutter_inappwebview_ios/lib/src/web_authentication_session/web_authenticate_session.dart index 9ef52c87..8d2160b1 100755 --- a/flutter_inappwebview_ios/lib/src/web_authentication_session/web_authenticate_session.dart +++ b/flutter_inappwebview_ios/lib/src/web_authentication_session/web_authenticate_session.dart @@ -90,10 +90,8 @@ class IOSWebAuthenticationSession extends PlatformWebAuthenticationSession WebAuthenticationSessionSettings? initialSettings}) : super.implementation(IOSWebAuthenticationSessionCreationParams()) { assert(url.toString().isNotEmpty); - if (Util.isIOS || Util.isMacOS) { - assert(['http', 'https'].contains(url.scheme), - 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); - } + assert(['http', 'https'].contains(url.scheme), + 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); this.initialSettings = initialSettings ?? WebAuthenticationSessionSettings(); diff --git a/flutter_inappwebview_macos/lib/src/cookie_manager.dart b/flutter_inappwebview_macos/lib/src/cookie_manager.dart index ca679132..3fbc69a0 100755 --- a/flutter_inappwebview_macos/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_macos/lib/src/cookie_manager.dart @@ -418,14 +418,9 @@ class MacOSCookieManager extends PlatformCookieManager } Future _shouldUseJavascript() async { - if (Util.isMacOS || Util.isMacOS) { - final platformUtil = PlatformUtil.instance(); - final systemVersion = await platformUtil.getSystemVersion(); - return Util.isMacOS - ? systemVersion.compareTo("11") == -1 - : systemVersion.compareTo("10.13") == -1; - } - return false; + final platformUtil = PlatformUtil.instance(); + final systemVersion = await platformUtil.getSystemVersion(); + return systemVersion.compareTo("11") == -1; } @override diff --git a/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart index 19b360b6..429f1273 100755 --- a/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart @@ -65,7 +65,7 @@ class MacOSInAppBrowser extends PlatformInAppBrowser with ChannelController { return _staticValue; } - MacOSInAppBrowserCreationParams get _iosParams => + MacOSInAppBrowserCreationParams get _macosParams => params as MacOSInAppBrowserCreationParams; static const MethodChannel _staticChannel = @@ -95,7 +95,7 @@ class MacOSInAppBrowser extends PlatformInAppBrowser with ChannelController { channel!, this, this.initialUserScripts); - _iosParams.findInteractionController?.init(id); + _macosParams.findInteractionController?.init(id); } _debugLog(String method, dynamic args) { diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart index 13d09f59..061bf43c 100644 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart @@ -274,7 +274,7 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView dynamic _controllerFromPlatform; - MacOSHeadlessInAppWebViewCreationParams get _iosParams => + MacOSHeadlessInAppWebViewCreationParams get _macosParams => params as MacOSHeadlessInAppWebViewCreationParams; _init() { @@ -285,7 +285,7 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView _controllerFromPlatform = params.controllerFromPlatform?.call(_webViewController!) ?? _webViewController!; - _iosParams.findInteractionController?.init(id); + _macosParams.findInteractionController?.init(id); channel = MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview_$id'); handler = _handleMethod; @@ -321,8 +321,8 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView initialSettings.toMap(); Map pullToRefreshSettings = - _iosParams.pullToRefreshController?.params.settings.toMap() ?? - _iosParams.pullToRefreshController?.params.options.toMap() ?? + _macosParams.pullToRefreshController?.params.settings.toMap() ?? + _macosParams.pullToRefreshController?.params.options.toMap() ?? PullToRefreshSettings(enabled: false).toMap(); Map args = {}; @@ -421,8 +421,8 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView _webViewController?.dispose(); _webViewController = null; _controllerFromPlatform = null; - _iosParams.pullToRefreshController?.dispose(); - _iosParams.findInteractionController?.dispose(); + _macosParams.pullToRefreshController?.dispose(); + _macosParams.findInteractionController?.dispose(); } } diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart index 4fbbddea..8669963d 100755 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart @@ -254,16 +254,11 @@ class MacOSInAppWebViewWidgetCreationParams final MacOSFindInteractionController? findInteractionController; } -///{@template flutter_inappwebview.InAppWebView} -///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree. -/// -///**Supported Platforms/Implementations**: -///- MacOS native WebView -///- iOS -///- Web -///{@endtemplate} +///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget} class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget { /// Constructs a [MacOSInAppWebViewWidget]. + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidget} MacOSInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params) : super.implementation( params is MacOSInAppWebViewWidgetCreationParams @@ -272,61 +267,61 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget { .fromPlatformInAppWebViewWidgetCreationParams(params), ); - MacOSInAppWebViewWidgetCreationParams get _iosParams => + MacOSInAppWebViewWidgetCreationParams get _macosParams => params as MacOSInAppWebViewWidgetCreationParams; MacOSInAppWebViewController? _controller; - MacOSHeadlessInAppWebView? get _iosHeadlessInAppWebView => - _iosParams.headlessWebView as MacOSHeadlessInAppWebView?; + MacOSHeadlessInAppWebView? get _macosHeadlessInAppWebView => + _macosParams.headlessWebView as MacOSHeadlessInAppWebView?; @override Widget build(BuildContext context) { final initialSettings = - _iosParams.initialSettings ?? InAppWebViewSettings(); + _macosParams.initialSettings ?? InAppWebViewSettings(); _inferInitialSettings(initialSettings); - Map settingsMap = (_iosParams.initialSettings != null + Map settingsMap = (_macosParams.initialSettings != null ? initialSettings.toMap() : null) ?? // ignore: deprecated_member_use_from_same_package - _iosParams.initialOptions?.toMap() ?? + _macosParams.initialOptions?.toMap() ?? initialSettings.toMap(); Map pullToRefreshSettings = - _iosParams.pullToRefreshController?.params.settings.toMap() ?? + _macosParams.pullToRefreshController?.params.settings.toMap() ?? // ignore: deprecated_member_use_from_same_package - _iosParams.pullToRefreshController?.params.options.toMap() ?? + _macosParams.pullToRefreshController?.params.options.toMap() ?? PullToRefreshSettings(enabled: false).toMap(); - if ((_iosParams.headlessWebView?.isRunning() ?? false) && - _iosParams.keepAlive != null) { - final headlessId = _iosParams.headlessWebView?.id; + if ((_macosParams.headlessWebView?.isRunning() ?? false) && + _macosParams.keepAlive != null) { + final headlessId = _macosParams.headlessWebView?.id; if (headlessId != null) { // force keep alive id to match headless webview id - _iosParams.keepAlive?.id = headlessId; + _macosParams.keepAlive?.id = headlessId; } } return UiKitView( viewType: 'com.pichillilorenzo/flutter_inappwebview', onPlatformViewCreated: _onPlatformViewCreated, - gestureRecognizers: _iosParams.gestureRecognizers, + gestureRecognizers: _macosParams.gestureRecognizers, creationParams: { - 'initialUrlRequest': _iosParams.initialUrlRequest?.toMap(), - 'initialFile': _iosParams.initialFile, - 'initialData': _iosParams.initialData?.toMap(), + 'initialUrlRequest': _macosParams.initialUrlRequest?.toMap(), + 'initialFile': _macosParams.initialFile, + 'initialData': _macosParams.initialData?.toMap(), 'initialSettings': settingsMap, - 'contextMenu': _iosParams.contextMenu?.toMap() ?? {}, - 'windowId': _iosParams.windowId, - 'headlessWebViewId': _iosParams.headlessWebView?.isRunning() ?? false - ? _iosParams.headlessWebView?.id + 'contextMenu': _macosParams.contextMenu?.toMap() ?? {}, + 'windowId': _macosParams.windowId, + 'headlessWebViewId': _macosParams.headlessWebView?.isRunning() ?? false + ? _macosParams.headlessWebView?.id : null, 'initialUserScripts': - _iosParams.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], + _macosParams.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], 'pullToRefreshSettings': pullToRefreshSettings, - 'keepAliveId': _iosParams.keepAlive?.id, - 'preventGestureDelay': _iosParams.preventGestureDelay + 'keepAliveId': _macosParams.keepAlive?.id, + 'preventGestureDelay': _macosParams.preventGestureDelay }, creationParamsCodec: const StandardMessageCodec(), ); @@ -335,16 +330,16 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget { void _onPlatformViewCreated(int id) { dynamic viewId = id; if (!kIsWeb) { - if (_iosParams.headlessWebView?.isRunning() ?? false) { - viewId = _iosParams.headlessWebView?.id; + if (_macosParams.headlessWebView?.isRunning() ?? false) { + viewId = _macosParams.headlessWebView?.id; } - viewId = _iosParams.keepAlive?.id ?? viewId ?? id; + viewId = _macosParams.keepAlive?.id ?? viewId ?? id; } - _iosHeadlessInAppWebView?.internalDispose(); + _macosHeadlessInAppWebView?.internalDispose(); _controller = MacOSInAppWebViewController( PlatformInAppWebViewControllerCreationParams( id: viewId, webviewParams: params)); - _iosParams.findInteractionController?.init(viewId); + _macosParams.findInteractionController?.init(viewId); debugLog( className: runtimeType.toString(), id: viewId?.toString(), @@ -352,42 +347,42 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget { PlatformInAppWebViewController.debugLoggingSettings, method: "onWebViewCreated", args: []); - if (_iosParams.onWebViewCreated != null) { - _iosParams.onWebViewCreated!( + if (_macosParams.onWebViewCreated != null) { + _macosParams.onWebViewCreated!( params.controllerFromPlatform?.call(_controller!) ?? _controller!); } } void _inferInitialSettings(InAppWebViewSettings settings) { - if (_iosParams.shouldOverrideUrlLoading != null && + if (_macosParams.shouldOverrideUrlLoading != null && settings.useShouldOverrideUrlLoading == null) { settings.useShouldOverrideUrlLoading = true; } - if (_iosParams.onLoadResource != null && + if (_macosParams.onLoadResource != null && settings.useOnLoadResource == null) { settings.useOnLoadResource = true; } - if (_iosParams.onDownloadStartRequest != null && + if (_macosParams.onDownloadStartRequest != null && settings.useOnDownloadStart == null) { settings.useOnDownloadStart = true; } - if (_iosParams.shouldInterceptAjaxRequest != null && + if (_macosParams.shouldInterceptAjaxRequest != null && settings.useShouldInterceptAjaxRequest == null) { settings.useShouldInterceptAjaxRequest = true; } - if (_iosParams.shouldInterceptFetchRequest != null && + if (_macosParams.shouldInterceptFetchRequest != null && settings.useShouldInterceptFetchRequest == null) { settings.useShouldInterceptFetchRequest = true; } - if (_iosParams.shouldInterceptRequest != null && + if (_macosParams.shouldInterceptRequest != null && settings.useShouldInterceptRequest == null) { settings.useShouldInterceptRequest = true; } - if (_iosParams.onRenderProcessGone != null && + if (_macosParams.onRenderProcessGone != null && settings.useOnRenderProcessGone == null) { settings.useOnRenderProcessGone = true; } - if (_iosParams.onNavigationResponse != null && + if (_macosParams.onNavigationResponse != null && settings.useOnNavigationResponse == null) { settings.useOnNavigationResponse = true; } @@ -403,11 +398,11 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget { PlatformInAppWebViewController.debugLoggingSettings, method: "dispose", args: []); - final isKeepAlive = _iosParams.keepAlive != null; + final isKeepAlive = _macosParams.keepAlive != null; _controller?.dispose(isKeepAlive: isKeepAlive); _controller = null; - _iosParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive); - _iosParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive); + _macosParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive); + _macosParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive); } @override diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 2fe7bfbe..3e13e4f5 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -48,16 +48,17 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSInAppWebViewController.static(); } - /// Creates a new [MacOSInAppWebViewWidget]. - /// - /// This function should only be called by the app-facing package. - /// Look at using [InAppWebView] in `flutter_inappwebview` instead. - @override - MacOSInAppWebViewWidget createPlatformInAppWebViewWidget( - PlatformInAppWebViewWidgetCreationParams params, - ) { - return MacOSInAppWebViewWidget(params); - } + // TODO: unhide when Flutter official PlatformView for macOS is available + // /// Creates a new [MacOSInAppWebViewWidget]. + // /// + // /// This function should only be called by the app-facing package. + // /// Look at using [InAppWebView] in `flutter_inappwebview` instead. + // @override + // MacOSInAppWebViewWidget createPlatformInAppWebViewWidget( + // PlatformInAppWebViewWidgetCreationParams params, + // ) { + // return MacOSInAppWebViewWidget(params); + // } /// Creates a new [MacOSFindInteractionController]. /// diff --git a/flutter_inappwebview_macos/lib/src/web_authentication_session/web_authenticate_session.dart b/flutter_inappwebview_macos/lib/src/web_authentication_session/web_authenticate_session.dart index 1cff8fda..33a59daa 100755 --- a/flutter_inappwebview_macos/lib/src/web_authentication_session/web_authenticate_session.dart +++ b/flutter_inappwebview_macos/lib/src/web_authentication_session/web_authenticate_session.dart @@ -90,10 +90,8 @@ class MacOSWebAuthenticationSession extends PlatformWebAuthenticationSession WebAuthenticationSessionSettings? initialSettings}) : super.implementation(MacOSWebAuthenticationSessionCreationParams()) { assert(url.toString().isNotEmpty); - if (Util.isMacOS || Util.isMacOS) { - assert(['http', 'https'].contains(url.scheme), - 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); - } + assert(['http', 'https'].contains(url.scheme), + 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); this.initialSettings = initialSettings ?? WebAuthenticationSessionSettings(); diff --git a/flutter_inappwebview_macos/lib/src/web_message/web_message_channel.dart b/flutter_inappwebview_macos/lib/src/web_message/web_message_channel.dart index adbaa2f6..80e16008 100644 --- a/flutter_inappwebview_macos/lib/src/web_message/web_message_channel.dart +++ b/flutter_inappwebview_macos/lib/src/web_message/web_message_channel.dart @@ -60,9 +60,9 @@ class MacOSWebMessageChannel extends PlatformWebMessageChannel return _staticValue; } - MacOSWebMessagePort get _iosPort1 => port1 as MacOSWebMessagePort; + MacOSWebMessagePort get _macosPort1 => port1 as MacOSWebMessagePort; - MacOSWebMessagePort get _iosPort2 => port2 as MacOSWebMessagePort; + MacOSWebMessagePort get _macosPort2 => port2 as MacOSWebMessagePort; static MacOSWebMessageChannel? _fromMap(Map? map) { if (map == null) { @@ -75,8 +75,8 @@ class MacOSWebMessageChannel extends PlatformWebMessageChannel MacOSWebMessagePortCreationParams(index: 0)), port2: MacOSWebMessagePort( MacOSWebMessagePortCreationParams(index: 1)))); - webMessageChannel._iosPort1.webMessageChannel = webMessageChannel; - webMessageChannel._iosPort2.webMessageChannel = webMessageChannel; + webMessageChannel._macosPort1.webMessageChannel = webMessageChannel; + webMessageChannel._macosPort2.webMessageChannel = webMessageChannel; return webMessageChannel; } @@ -84,7 +84,7 @@ class MacOSWebMessageChannel extends PlatformWebMessageChannel switch (call.method) { case "onMessage": int index = call.arguments["index"]; - var port = index == 0 ? _iosPort1 : _iosPort2; + var port = index == 0 ? _macosPort1 : _macosPort2; if (port.onMessage != null) { WebMessage? message = call.arguments["message"] != null ? WebMessage.fromMap( diff --git a/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart index 87b66bf7..b2791eba 100644 --- a/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart +++ b/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart @@ -47,7 +47,7 @@ class MacOSWebMessageListener extends PlatformWebMessageListener : MacOSWebMessageListenerCreationParams .fromPlatformWebMessageListenerCreationParams(params), ) { - assert(!this._iosParams.allowedOriginRules.contains(""), + assert(!this._macosParams.allowedOriginRules.contains(""), "allowedOriginRules cannot contain empty strings"); channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_web_message_listener_${_id}_${params.jsObjectName}'); @@ -60,7 +60,7 @@ class MacOSWebMessageListener extends PlatformWebMessageListener MacOSJavaScriptReplyProxy? _replyProxy; - MacOSWebMessageListenerCreationParams get _iosParams => + MacOSWebMessageListenerCreationParams get _macosParams => params as MacOSWebMessageListenerCreationParams; Future _handleMethod(MethodCall call) async { @@ -99,7 +99,7 @@ class MacOSWebMessageListener extends PlatformWebMessageListener return { "id": _id, "jsObjectName": params.jsObjectName, - "allowedOriginRules": _iosParams.allowedOriginRules.toList(), + "allowedOriginRules": _macosParams.allowedOriginRules.toList(), }; } @@ -147,14 +147,14 @@ class MacOSJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy { .fromPlatformJavaScriptReplyProxyCreationParams(params), ); - MacOSWebMessageListener get _iosWebMessageListener => + MacOSWebMessageListener get _macosWebMessageListener => params.webMessageListener as MacOSWebMessageListener; @override Future postMessage(WebMessage message) async { Map args = {}; args.putIfAbsent('message', () => message.toMap()); - await _iosWebMessageListener.channel?.invokeMethod('postMessage', args); + await _macosWebMessageListener.channel?.invokeMethod('postMessage', args); } @override diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart index 15947eb8..0bd6c851 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart @@ -144,7 +144,8 @@ class PlatformAssetsPathHandlerCreationParams ///Developers should ensure that asset files are named using standard file extensions. ///If the file does not have a recognised extension, `text/plain` will be used by default. ///{@endtemplate} -abstract class PlatformAssetsPathHandler extends PlatformInterface implements PlatformPathHandler { +abstract class PlatformAssetsPathHandler extends PlatformInterface + implements PlatformPathHandler { /// Creates a new [PlatformAssetsPathHandler] factory PlatformAssetsPathHandler( PlatformAssetsPathHandlerCreationParams params) { @@ -216,7 +217,8 @@ class PlatformResourcesPathHandlerCreationParams ///Developers should ensure that asset files are named using standard file extensions. ///If the file does not have a recognised extension, `text/plain` will be used by default. ///{@endtemplate} -abstract class PlatformResourcesPathHandler extends PlatformInterface implements PlatformPathHandler { +abstract class PlatformResourcesPathHandler extends PlatformInterface + implements PlatformPathHandler { /// Creates a new [PlatformResourcesPathHandler] factory PlatformResourcesPathHandler( PlatformResourcesPathHandlerCreationParams params) { @@ -239,7 +241,8 @@ abstract class PlatformResourcesPathHandler extends PlatformInterface implements /// Should only be used by platform implementations because they can't extend /// a class that only contains a factory constructor. @protected - PlatformResourcesPathHandler.implementation(this.params) : super(token: _token); + PlatformResourcesPathHandler.implementation(this.params) + : super(token: _token); static final Object _token = Object(); @@ -299,7 +302,8 @@ class PlatformInternalStoragePathHandlerCreationParams ///Developers should ensure that asset files are named using standard file extensions. ///If the file does not have a recognised extension, `text/plain` will be used by default. ///{@endtemplate} -abstract class PlatformInternalStoragePathHandler extends PlatformInterface implements PlatformPathHandler { +abstract class PlatformInternalStoragePathHandler extends PlatformInterface + implements PlatformPathHandler { /// Creates a new [PlatformResourcesPathHandler] factory PlatformInternalStoragePathHandler( PlatformInternalStoragePathHandlerCreationParams params) { @@ -322,7 +326,8 @@ abstract class PlatformInternalStoragePathHandler extends PlatformInterface impl /// Should only be used by platform implementations because they can't extend /// a class that only contains a factory constructor. @protected - PlatformInternalStoragePathHandler.implementation(this.params) : super(token: _token); + PlatformInternalStoragePathHandler.implementation(this.params) + : super(token: _token); static final Object _token = Object();