From 5476d142f4a8f79e85d4997bdd443715d309d799 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 7 Sep 2020 10:32:24 +0200 Subject: [PATCH] fix #507 --- CHANGELOG.md | 1 + example/.flutter-plugins-dependencies | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 2 -- lib/src/in_app_webview_controller.dart | 14 +++++++------- lib/src/types.dart | 20 ++++++++++---------- lib/src/webview_options.dart | 4 ++-- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fee2cfd2..bf68da06 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Merge "Added missing field 'headers' which returned by WebResourceResponse.toMap()" [#490](https://github.com/pichillilorenzo/flutter_inappwebview/pull/490) (thanks to [Doflatango](https://github.com/Doflatango)) - Merge "Fix: added iOS fallback module import" [#466](https://github.com/pichillilorenzo/flutter_inappwebview/pull/466) (thanks to [Eddayy](https://github.com/Eddayy)) - Merge "Fix NullPointerException after taking a photo by a camera app on Android" [#492](https://github.com/pichillilorenzo/flutter_inappwebview/pull/492) (thanks to [AAkira](https://github.com/AAkira)) +- Fixed "Issue in Flutter web: 'Unsupported operation: Platform._operatingSystem'" [#507](https://github.com/pichillilorenzo/flutter_inappwebview/issues/507) - Fixed "window.flutter_inappwebview.callHandler is not a function" [#218](https://github.com/pichillilorenzo/flutter_inappwebview/issues/218) ## 4.0.0+4 diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 7b0a63d8..ac50076a 100755 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]}],"android":[{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"url_launcher_web","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_inappwebview","dependencies":[]},{"name":"e2e","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-08-27 17:01:18.942482","version":"1.20.2"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]}],"android":[{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.10/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.11/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"url_launcher_web","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_inappwebview","dependencies":[]},{"name":"e2e","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-09-07 10:28:45.900709","version":"1.20.3"} \ No newline at end of file diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 788bac68..8610a573 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -325,7 +325,6 @@ /* Begin XCBuildConfiguration section */ 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -383,7 +382,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; diff --git a/lib/src/in_app_webview_controller.dart b/lib/src/in_app_webview_controller.dart index 900dc362..b2ae8edf 100644 --- a/lib/src/in_app_webview_controller.dart +++ b/lib/src/in_app_webview_controller.dart @@ -471,7 +471,7 @@ class InAppWebViewController { SslCertificate sslCertificate; if (sslCertificateMap != null) { - if (Platform.isIOS) { + if (defaultTargetPlatform == TargetPlatform.iOS) { try { X509Certificate x509certificate = X509Certificate.fromData( data: sslCertificateMap["x509Certificate"]); @@ -670,8 +670,8 @@ class InAppWebViewController { androidId: androidId, iosId: iosId, title: title, action: null); for (var menuItem in contextMenu.menuItems) { - if ((Platform.isAndroid && menuItem.androidId == androidId) || - (Platform.isIOS && menuItem.iosId == iosId)) { + if ((defaultTargetPlatform == TargetPlatform.android && menuItem.androidId == androidId) || + (defaultTargetPlatform == TargetPlatform.iOS && menuItem.iosId == iosId)) { menuItemClicked = menuItem; menuItem?.action(); break; @@ -1348,7 +1348,7 @@ class InAppWebViewController { Map args = {}; args.putIfAbsent('source', () => source); var data = await _channel.invokeMethod('evaluateJavascript', args); - if (data != null && Platform.isAndroid) data = json.decode(data); + if (data != null && defaultTargetPlatform == TargetPlatform.android) data = json.decode(data); return data; } @@ -1693,8 +1693,8 @@ class InAppWebViewController { /// ///**Official iOS API**: https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale Future zoomBy(double zoomFactor) async { - assert(!Platform.isAndroid || - (Platform.isAndroid && zoomFactor > 0.01 && zoomFactor <= 100.0)); + assert(defaultTargetPlatform != TargetPlatform.android || + (defaultTargetPlatform == TargetPlatform.android && zoomFactor > 0.01 && zoomFactor <= 100.0)); Map args = {}; args.putIfAbsent('zoomFactor', () => zoomFactor); @@ -1907,7 +1907,7 @@ class InAppWebViewController { ?.cast(); if (sslCertificateMap != null) { - if (Platform.isIOS) { + if (defaultTargetPlatform == TargetPlatform.iOS) { try { X509Certificate x509certificate = X509Certificate.fromData( data: sslCertificateMap["x509Certificate"]); diff --git a/lib/src/types.dart b/lib/src/types.dart index 9df619dd..e22d7ffb 100755 --- a/lib/src/types.dart +++ b/lib/src/types.dart @@ -2014,9 +2014,9 @@ class InAppWebViewGroupOptions { Map toMap() { Map options = {}; options.addAll(this.crossPlatform?.toMap() ?? {}); - if (Platform.isAndroid) + if (defaultTargetPlatform == TargetPlatform.android) options.addAll(this.android?.toMap() ?? {}); - else if (Platform.isIOS) options.addAll(this.ios?.toMap() ?? {}); + else if (defaultTargetPlatform == TargetPlatform.iOS) options.addAll(this.ios?.toMap() ?? {}); return options; } @@ -2027,10 +2027,10 @@ class InAppWebViewGroupOptions { inAppWebViewGroupOptions.crossPlatform = InAppWebViewOptions.fromMap(options); - if (Platform.isAndroid) + if (defaultTargetPlatform == TargetPlatform.android) inAppWebViewGroupOptions.android = AndroidInAppWebViewOptions.fromMap(options); - else if (Platform.isIOS) + else if (defaultTargetPlatform == TargetPlatform.iOS) inAppWebViewGroupOptions.ios = IOSInAppWebViewOptions.fromMap(options); return inAppWebViewGroupOptions; @@ -2081,10 +2081,10 @@ class InAppBrowserClassOptions { options.addAll(this.crossPlatform?.toMap() ?? {}); options.addAll(this.inAppWebViewGroupOptions?.crossPlatform?.toMap() ?? {}); - if (Platform.isAndroid) { + if (defaultTargetPlatform == TargetPlatform.android) { options.addAll(this.android?.toMap() ?? {}); options.addAll(this.inAppWebViewGroupOptions?.android?.toMap() ?? {}); - } else if (Platform.isIOS) { + } else if (defaultTargetPlatform == TargetPlatform.iOS) { options.addAll(this.ios?.toMap() ?? {}); options.addAll(this.inAppWebViewGroupOptions?.ios?.toMap() ?? {}); } @@ -2111,12 +2111,12 @@ class InAppBrowserClassOptions { InAppWebViewGroupOptions(); inAppBrowserClassOptions.inAppWebViewGroupOptions.crossPlatform = InAppWebViewOptions.fromMap(options); - if (Platform.isAndroid) { + if (defaultTargetPlatform == TargetPlatform.android) { inAppBrowserClassOptions.android = AndroidInAppBrowserOptions.fromMap(options); inAppBrowserClassOptions.inAppWebViewGroupOptions.android = AndroidInAppWebViewOptions.fromMap(options); - } else if (Platform.isIOS) { + } else if (defaultTargetPlatform == TargetPlatform.iOS) { inAppBrowserClassOptions.ios = IOSInAppBrowserOptions.fromMap(options); inAppBrowserClassOptions.inAppWebViewGroupOptions.ios = IOSInAppWebViewOptions.fromMap(options); @@ -2145,9 +2145,9 @@ class ChromeSafariBrowserClassOptions { Map toMap() { Map options = {}; - if (Platform.isAndroid) + if (defaultTargetPlatform == TargetPlatform.android) options.addAll(this.android?.toMap() ?? {}); - else if (Platform.isIOS) options.addAll(this.ios?.toMap() ?? {}); + else if (defaultTargetPlatform == TargetPlatform.iOS) options.addAll(this.ios?.toMap() ?? {}); return options; } diff --git a/lib/src/webview_options.dart b/lib/src/webview_options.dart index ccd0c3a6..9391de7b 100755 --- a/lib/src/webview_options.dart +++ b/lib/src/webview_options.dart @@ -1,4 +1,4 @@ -import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'content_blocker.dart'; import 'types.dart'; @@ -201,7 +201,7 @@ class InAppWebViewOptions this.disableContextMenu = false, this.supportZoom = true}) { if (this.minimumFontSize == null) - this.minimumFontSize = Platform.isAndroid ? 8 : 0; + this.minimumFontSize = defaultTargetPlatform == TargetPlatform.android ? 8 : 0; assert(!this.resourceCustomSchemes.contains("http") && !this.resourceCustomSchemes.contains("https")); }