Skip to content

Commit

Permalink
fix #507 again
Browse files Browse the repository at this point in the history
  • Loading branch information
pichillilorenzo committed Mar 8, 2021
1 parent c9f8466 commit 659c524
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.1.0+3

- Fixed "Unsupported operation: Platform._operatingSystem" when compiling for Web again [#507](https://github.com/pichillilorenzo/flutter_inappwebview/issues/507)

## 5.1.0+2

- Fixed missing MATCH_PARENT layout params to the WebView on Android when it is wrapped by PullToRefreshLayout
Expand Down
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"android":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.5-nullsafety/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.1.0-nullsafety.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.2.0-nullsafety/","dependencies":[]},{"name":"url_launcher_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.1.0-nullsafety.3/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.1.0-nullsafety.3/","dependencies":[]},{"name":"url_launcher_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-0.1.0-nullsafety.2/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-03-06 16:03:42.653087","version":"2.1.0-10.0.pre"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"android":[{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.5-nullsafety/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.1.0-nullsafety.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.2.0-nullsafety/","dependencies":[]},{"name":"url_launcher_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.1.0-nullsafety.3/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.1.0-nullsafety.3/","dependencies":[]},{"name":"url_launcher_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-0.1.0-nullsafety.2/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-03-08 10:08:44.020151","version":"2.1.0-10.0.pre"}
11 changes: 6 additions & 5 deletions lib/src/cookie_manager.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'in_app_webview/in_app_webview_controller.dart';
Expand Down Expand Up @@ -70,7 +71,7 @@ class CookieManager {
assert(domain.isNotEmpty);
assert(path.isNotEmpty);

if (Platform.isIOS) {
if (defaultTargetPlatform == TargetPlatform.iOS) {
var platformUtil = PlatformUtil();
var version = double.tryParse(await platformUtil.getSystemVersion());
if (version != null && version < 11.0) {
Expand Down Expand Up @@ -166,7 +167,7 @@ class CookieManager {
InAppWebViewController? iosBelow11WebViewController}) async {
assert(url.toString().isNotEmpty);

if (Platform.isIOS) {
if (defaultTargetPlatform == TargetPlatform.iOS) {
var platformUtil = PlatformUtil();
var version = double.tryParse(await platformUtil.getSystemVersion());
if (version != null && version < 11.0) {
Expand Down Expand Up @@ -265,7 +266,7 @@ class CookieManager {
assert(url.toString().isNotEmpty);
assert(name.isNotEmpty);

if (Platform.isIOS) {
if (defaultTargetPlatform == TargetPlatform.iOS) {
var platformUtil = PlatformUtil();
var version = double.tryParse(await platformUtil.getSystemVersion());
if (version != null && version < 11.0) {
Expand Down Expand Up @@ -321,7 +322,7 @@ class CookieManager {
assert(url.toString().isNotEmpty);
assert(name.isNotEmpty);

if (Platform.isIOS) {
if (defaultTargetPlatform == TargetPlatform.iOS) {
var platformUtil = PlatformUtil();
var version = double.tryParse(await platformUtil.getSystemVersion());
if (version != null && version < 11.0) {
Expand Down Expand Up @@ -365,7 +366,7 @@ class CookieManager {

assert(url.toString().isNotEmpty);

if (Platform.isIOS) {
if (defaultTargetPlatform == TargetPlatform.iOS) {
var platformUtil = PlatformUtil();
var version = double.tryParse(await platformUtil.getSystemVersion());
if (version != null && version < 11.0) {
Expand Down
16 changes: 8 additions & 8 deletions lib/src/in_app_webview/in_app_webview_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ class InAppWebViewController {
///
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript
Future<void> addUserScript({required UserScript userScript}) async {
assert(_webview?.windowId == null || !Platform.isIOS);
assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS);

Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('userScript', () => userScript.toMap());
Expand All @@ -1924,7 +1924,7 @@ class InAppWebViewController {
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
Future<void> addUserScripts({required List<UserScript> userScripts}) async {
assert(_webview?.windowId == null || !Platform.isIOS);
assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS);

for (var i = 0; i < userScripts.length; i++) {
await addUserScript(userScript: userScripts[i]);
Expand All @@ -1939,7 +1939,7 @@ class InAppWebViewController {
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
Future<bool> removeUserScript({required UserScript userScript}) async {
assert(_webview?.windowId == null || !Platform.isIOS);
assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS);

var index = _userScripts.indexOf(userScript);
if (index == -1) {
Expand All @@ -1962,7 +1962,7 @@ class InAppWebViewController {
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
Future<void> removeUserScriptsByGroupName({required String groupName}) async {
assert(_webview?.windowId == null || !Platform.isIOS);
assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS);

Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('groupName', () => groupName);
Expand All @@ -1977,7 +1977,7 @@ class InAppWebViewController {
///This is a limitation of the native iOS WebKit APIs.
Future<void> removeUserScripts(
{required List<UserScript> userScripts}) async {
assert(_webview?.windowId == null || !Platform.isIOS);
assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS);

for (var i = 0; i < userScripts.length; i++) {
await removeUserScript(userScript: userScripts[i]);
Expand All @@ -1992,7 +1992,7 @@ class InAppWebViewController {
///
///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts
Future<void> removeAllUserScripts() async {
assert(_webview?.windowId == null || !Platform.isIOS);
assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS);

_userScripts.clear();
Map<String, dynamic> args = <String, dynamic>{};
Expand Down Expand Up @@ -2059,9 +2059,9 @@ class InAppWebViewController {
Future<String?> saveWebArchive(
{required String filePath, bool autoname = false}) async {
if (!autoname) {
if (Platform.isAndroid) {
if (defaultTargetPlatform == TargetPlatform.android) {
assert(filePath.endsWith("." + WebArchiveFormat.MHT.toValue()));
} else if (Platform.isIOS) {
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
assert(filePath.endsWith("." + WebArchiveFormat.WEBARCHIVE.toValue()));
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_inappwebview
description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
version: 5.1.0+2
version: 5.1.0+3
homepage: https://github.com/pichillilorenzo/flutter_inappwebview

environment:
Expand Down

0 comments on commit 659c524

Please sign in to comment.