From 7307d473fafe7d3cb45ee88e94a9a634e0f6b4e1 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Tue, 19 Apr 2022 00:42:57 +0200 Subject: [PATCH] dartfmt, fixed pubspec.yaml --- .fvm/flutter_sdk | 1 - .fvm/fvm_config.json | 4 -- .gitignore | 3 + example/pubspec.yaml | 2 + .../android/chrome_custom_tabs_options.dart | 5 +- lib/src/in_app_browser/in_app_browser.dart | 5 +- .../headless_in_app_webview.dart | 9 +-- lib/src/in_app_webview/in_app_webview.dart | 4 +- .../in_app_webview_controller.dart | 48 +++++++++++----- lib/src/in_app_webview/webview.dart | 9 +-- lib/src/types.dart | 57 ++++++++++--------- pubspec.yaml | 4 ++ scripts/test_and_log.sh | 8 +++ 13 files changed, 100 insertions(+), 59 deletions(-) delete mode 120000 .fvm/flutter_sdk delete mode 100644 .fvm/fvm_config.json create mode 100755 scripts/test_and_log.sh diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk deleted file mode 120000 index c6e3b15b..00000000 --- a/.fvm/flutter_sdk +++ /dev/null @@ -1 +0,0 @@ -/Users/lorenzopichilli/fvm/versions/2.10.4 \ No newline at end of file diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json deleted file mode 100644 index d2faf497..00000000 --- a/.fvm/fvm_config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flutterSdkVersion": "2.10.4", - "flavors": {} -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9be145fd..4bf314d6 100755 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ .dart_tool/ .packages build/ +.fvm/ + +flutter_driver_tests.log \ No newline at end of file diff --git a/example/pubspec.yaml b/example/pubspec.yaml index aa1622d8..7789db22 100755 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,6 +9,8 @@ description: Demonstrates how to use the flutter_inappwebview plugin. # Read more about versioning at semver.org. version: 1.0.0+1 +publish_to: none + environment: sdk: ">=2.14.0 <3.0.0" flutter: ">=2.5.0" diff --git a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart index 2496ade2..137a076f 100755 --- a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart +++ b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart @@ -126,9 +126,10 @@ class AndroidChromeCustomTabsOptions options.noHistory = map["noHistory"]; options.isTrustedWebActivity = map["isTrustedWebActivity"]; options.additionalTrustedOrigins = map["additionalTrustedOrigins"]; - switch(map["displayMode"]["type"]) { + switch (map["displayMode"]["type"]) { case "IMMERSIVE_MODE": - options.displayMode = TrustedWebActivityImmersiveDisplayMode.fromMap(map["displayMode"]); + options.displayMode = + TrustedWebActivityImmersiveDisplayMode.fromMap(map["displayMode"]); break; case "DEFAULT_MODE": default: diff --git a/lib/src/in_app_browser/in_app_browser.dart b/lib/src/in_app_browser/in_app_browser.dart index 74f45c1b..26e47832 100755 --- a/lib/src/in_app_browser/in_app_browser.dart +++ b/lib/src/in_app_browser/in_app_browser.dart @@ -69,7 +69,10 @@ class InAppBrowser { final WebViewImplementation implementation; /// - InAppBrowser({this.windowId, this.initialUserScripts, this.implementation = WebViewImplementation.NATIVE}) { + InAppBrowser( + {this.windowId, + this.initialUserScripts, + this.implementation = WebViewImplementation.NATIVE}) { id = IdGenerator.generate(); this._channel = MethodChannel('com.pichillilorenzo/flutter_inappbrowser_$id'); 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 7507cb3a..839f2da7 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -64,7 +64,8 @@ class HeadlessInAppWebView implements WebView { this.shouldOverrideUrlLoading, this.onLoadResource, this.onScrollChanged, - @Deprecated('Use `onDownloadStartRequest` instead') this.onDownloadStart, + @Deprecated('Use `onDownloadStartRequest` instead') + this.onDownloadStart, this.onDownloadStartRequest, this.onLoadResourceCustomScheme, this.onCreateWindow, @@ -306,11 +307,11 @@ class HeadlessInAppWebView implements WebView { @Deprecated('Use `onDownloadStartRequest` instead') @override final void Function(InAppWebViewController controller, Uri url)? - onDownloadStart; + onDownloadStart; @override - final void Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? - onDownloadStartRequest; + final void Function(InAppWebViewController controller, + DownloadStartRequest downloadStartRequest)? onDownloadStartRequest; @override void Function(InAppWebViewController controller, int activeMatchOrdinal, diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index c136fa22..ba08fc29 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -219,8 +219,8 @@ class InAppWebView extends StatefulWidget implements WebView { onDownloadStart; @override - final void Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? - onDownloadStartRequest; + final void Function(InAppWebViewController controller, + DownloadStartRequest downloadStartRequest)? onDownloadStartRequest; @override final void Function(InAppWebViewController controller, int activeMatchOrdinal, 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 998e64d6..b2be39c4 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -203,11 +203,14 @@ class InAppWebViewController { break; case "onDownloadStartRequest": if ((_webview != null && - // ignore: deprecated_member_use_from_same_package - (_webview!.onDownloadStart != null || _webview!.onDownloadStartRequest != null)) || + // ignore: deprecated_member_use_from_same_package + (_webview!.onDownloadStart != null || + _webview!.onDownloadStartRequest != null)) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - DownloadStartRequest downloadStartRequest = DownloadStartRequest.fromMap(arguments)!; + Map arguments = + call.arguments.cast(); + DownloadStartRequest downloadStartRequest = + DownloadStartRequest.fromMap(arguments)!; if (_webview != null) { if (_webview!.onDownloadStartRequest != null) @@ -1163,7 +1166,10 @@ class InAppWebViewController { ///- Android native WebView ([Official API - WebView.loadUrl](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))). If method is "POST", [Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])) ///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)) Future loadUrl( - {required URLRequest urlRequest, @Deprecated('Use `allowingReadAccessTo` instead') Uri? iosAllowingReadAccessTo, Uri? allowingReadAccessTo}) async { + {required URLRequest urlRequest, + @Deprecated('Use `allowingReadAccessTo` instead') + Uri? iosAllowingReadAccessTo, + Uri? allowingReadAccessTo}) async { assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty); assert(iosAllowingReadAccessTo == null || iosAllowingReadAccessTo.isScheme("file")); @@ -1171,7 +1177,10 @@ class InAppWebViewController { Map args = {}; args.putIfAbsent('urlRequest', () => urlRequest.toMap()); args.putIfAbsent( - 'allowingReadAccessTo', () => allowingReadAccessTo?.toString() ?? iosAllowingReadAccessTo?.toString()); + 'allowingReadAccessTo', + () => + allowingReadAccessTo?.toString() ?? + iosAllowingReadAccessTo?.toString()); await _channel.invokeMethod('loadUrl', args); } @@ -1215,10 +1224,10 @@ class InAppWebViewController { String encoding = "utf8", Uri? baseUrl, @Deprecated('Use `historyUrl` instead') - Uri? androidHistoryUrl, + Uri? androidHistoryUrl, Uri? historyUrl, @Deprecated('Use `allowingReadAccessTo` instead') - Uri? iosAllowingReadAccessTo, + Uri? iosAllowingReadAccessTo, Uri? allowingReadAccessTo}) async { assert(iosAllowingReadAccessTo == null || iosAllowingReadAccessTo.isScheme("file")); @@ -1229,9 +1238,16 @@ class InAppWebViewController { args.putIfAbsent('encoding', () => encoding); args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank"); args.putIfAbsent( - 'historyUrl', () => historyUrl?.toString() ?? androidHistoryUrl?.toString() ?? "about:blank"); + 'historyUrl', + () => + historyUrl?.toString() ?? + androidHistoryUrl?.toString() ?? + "about:blank"); args.putIfAbsent( - 'allowingReadAccessTo', () => allowingReadAccessTo?.toString() ?? iosAllowingReadAccessTo?.toString()); + 'allowingReadAccessTo', + () => + allowingReadAccessTo?.toString() ?? + iosAllowingReadAccessTo?.toString()); await _channel.invokeMethod('loadData', args); } @@ -1706,8 +1722,8 @@ class InAppWebViewController { ///- Android native WebView ///- iOS Future getTRexRunnerHtml() async { - return await rootBundle - .loadString("packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html"); + return await rootBundle.loadString( + "packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html"); } ///Gets the css of the Chromium's t-rex runner game. Used in combination with [getTRexRunnerHtml]. @@ -1716,8 +1732,8 @@ class InAppWebViewController { ///- Android native WebView ///- iOS Future getTRexRunnerCss() async { - return await rootBundle - .loadString("packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css"); + return await rootBundle.loadString( + "packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css"); } ///Scrolls the WebView to the position. @@ -1820,7 +1836,9 @@ class InAppWebViewController { ///- Android native WebView ([Official API - WebView.zoomBy](https://developer.android.com/reference/android/webkit/WebView#zoomBy(float))) ///- iOS ([Official API - UIScrollView.setZoomScale](https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale)) Future zoomBy( - {required double zoomFactor, @Deprecated('Use `animated` instead') bool? iosAnimated, bool animated = false}) async { + {required double zoomFactor, + @Deprecated('Use `animated` instead') bool? iosAnimated, + bool animated = false}) async { assert(defaultTargetPlatform != TargetPlatform.android || (defaultTargetPlatform == TargetPlatform.android && zoomFactor > 0.01 && diff --git a/lib/src/in_app_webview/webview.dart b/lib/src/in_app_webview/webview.dart index 19a2f2ab..99dbc4a7 100644 --- a/lib/src/in_app_webview/webview.dart +++ b/lib/src/in_app_webview/webview.dart @@ -127,8 +127,8 @@ abstract class WebView { ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener) /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview - final void Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? - onDownloadStartRequest; + final void Function(InAppWebViewController controller, + DownloadStartRequest downloadStartRequest)? onDownloadStartRequest; ///Event fired when the [WebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`. /// @@ -701,7 +701,8 @@ abstract class WebView { this.shouldOverrideUrlLoading, this.onLoadResource, this.onScrollChanged, - @Deprecated('Use `onDownloadStartRequest` instead') this.onDownloadStart, + @Deprecated('Use `onDownloadStartRequest` instead') + this.onDownloadStart, this.onDownloadStartRequest, this.onLoadResourceCustomScheme, this.onCreateWindow, @@ -738,7 +739,7 @@ abstract class WebView { this.androidOnRenderProcessUnresponsive, this.androidOnFormResubmission, @Deprecated('Use `onZoomScaleChanged` instead') - this.androidOnScaleChanged, + this.androidOnScaleChanged, this.androidOnReceivedIcon, this.androidOnReceivedTouchIconUrl, this.androidOnJsBeforeUnload, diff --git a/lib/src/types.dart b/lib/src/types.dart index fcd82656..18676438 100755 --- a/lib/src/types.dart +++ b/lib/src/types.dart @@ -6857,9 +6857,8 @@ class WebViewImplementation { const WebViewImplementation._internal(this._value); - static final Set values = [ - WebViewImplementation.NATIVE - ].toSet(); + static final Set values = + [WebViewImplementation.NATIVE].toSet(); static WebViewImplementation? fromValue(int? value) { if (value != null) { @@ -6918,12 +6917,12 @@ class DownloadStartRequest { DownloadStartRequest( {required this.url, - this.userAgent, - this.contentDisposition, - this.mimeType, - required this.contentLength, - this.suggestedFilename, - this.textEncodingName}); + this.userAgent, + this.contentDisposition, + this.mimeType, + required this.contentLength, + this.suggestedFilename, + this.textEncodingName}); static DownloadStartRequest? fromMap(Map? map) { if (map == null) { @@ -7034,14 +7033,12 @@ abstract class TrustedWebActivityDisplayMode { ///Android-class that represents the default display mode of a Trusted Web Activity. ///The system UI (status bar, navigation bar) is shown, and the browser toolbar is hidden while the user is on a verified origin. -class TrustedWebActivityDefaultDisplayMode implements TrustedWebActivityDisplayMode { - +class TrustedWebActivityDefaultDisplayMode + implements TrustedWebActivityDisplayMode { String _type = "DEFAULT_MODE"; Map toMap() { - return { - "type": _type - }; + return {"type": _type}; } Map toJson() { @@ -7056,7 +7053,8 @@ class TrustedWebActivityDefaultDisplayMode implements TrustedWebActivityDisplayM ///Android-class that represents the default display mode of a Trusted Web Activity. ///The system UI (status bar, navigation bar) is shown, and the browser toolbar is hidden while the user is on a verified origin. -class TrustedWebActivityImmersiveDisplayMode implements TrustedWebActivityDisplayMode { +class TrustedWebActivityImmersiveDisplayMode + implements TrustedWebActivityDisplayMode { ///Whether the Trusted Web Activity should be in sticky immersive mode. bool isSticky; @@ -7066,10 +7064,10 @@ class TrustedWebActivityImmersiveDisplayMode implements TrustedWebActivityDispla String _type = "IMMERSIVE_MODE"; TrustedWebActivityImmersiveDisplayMode( - {required this.isSticky, - required this.layoutInDisplayCutoutMode}); + {required this.isSticky, required this.layoutInDisplayCutoutMode}); - static TrustedWebActivityImmersiveDisplayMode? fromMap(Map? map) { + static TrustedWebActivityImmersiveDisplayMode? fromMap( + Map? map) { if (map == null) { return null; } @@ -7149,7 +7147,8 @@ class AndroidLayoutInDisplayCutoutMode { ///Content renders into the cutout area in both portrait and landscape modes. /// ///**NOTE**: available on Android 28+. - static const SHORT_EDGES = const AndroidLayoutInDisplayCutoutMode._internal(1); + static const SHORT_EDGES = + const AndroidLayoutInDisplayCutoutMode._internal(1); ///Content never renders into the cutout area. /// @@ -7232,22 +7231,26 @@ class TrustedWebActivityScreenOrientation { /// Portrait-primary is an orientation where the screen width is less than or equal to the /// screen height. If the device's natural orientation is portrait, then it is in /// portrait-primary when held in that position. - static const PORTRAIT_PRIMARY = const TrustedWebActivityScreenOrientation._internal(1); + static const PORTRAIT_PRIMARY = + const TrustedWebActivityScreenOrientation._internal(1); /// Portrait-secondary is an orientation where the screen width is less than or equal to the /// screen height. If the device's natural orientation is portrait, then it is in /// portrait-secondary when rotated 180° from its natural position. - static const PORTRAIT_SECONDARY = const TrustedWebActivityScreenOrientation._internal(2); + static const PORTRAIT_SECONDARY = + const TrustedWebActivityScreenOrientation._internal(2); /// Landscape-primary is an orientation where the screen width is greater than the screen height. /// If the device's natural orientation is landscape, then it is in landscape-primary when held /// in that position. - static const LANDSCAPE_PRIMARY = const TrustedWebActivityScreenOrientation._internal(3); + static const LANDSCAPE_PRIMARY = + const TrustedWebActivityScreenOrientation._internal(3); /// Landscape-secondary is an orientation where the screen width is greater than the /// screen height. If the device's natural orientation is landscape, it is in /// landscape-secondary when rotated 180° from its natural orientation. - static const LANDSCAPE_SECONDARY = const TrustedWebActivityScreenOrientation._internal(4); + static const LANDSCAPE_SECONDARY = + const TrustedWebActivityScreenOrientation._internal(4); /// Any is an orientation that means the screen can be locked to any one of portrait-primary, /// portrait-secondary, landscape-primary and landscape-secondary. @@ -7256,12 +7259,14 @@ class TrustedWebActivityScreenOrientation { /// Landscape is an orientation where the screen width is greater than the screen height and /// depending on platform convention locking the screen to landscape can represent /// landscape-primary, landscape-secondary or both. - static const LANDSCAPE = const TrustedWebActivityScreenOrientation._internal(6); + static const LANDSCAPE = + const TrustedWebActivityScreenOrientation._internal(6); /// Portrait is an orientation where the screen width is less than or equal to the screen height /// and depending on platform convention locking the screen to portrait can represent /// portrait-primary, portrait-secondary or both. - static const PORTRAIT = const TrustedWebActivityScreenOrientation._internal(7); + static const PORTRAIT = + const TrustedWebActivityScreenOrientation._internal(7); /// Natural is an orientation that refers to either portrait-primary or landscape-primary /// depending on the device's usual orientation. This orientation is usually provided by @@ -7272,4 +7277,4 @@ class TrustedWebActivityScreenOrientation { @override int get hashCode => _value.hashCode; -} \ No newline at end of file +} diff --git a/pubspec.yaml b/pubspec.yaml index 861af6fd..3a9dbbea 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,3 +62,7 @@ flutter: # # For details regarding fonts in packages, see # https://flutter.io/custom-fonts/#from-packages + +false_secrets: + - /nodejs_server_test_auth_basic_and_ssl/*.pem + - /nodejs_server_test_auth_basic_and_ssl/*.pfx \ No newline at end of file diff --git a/scripts/test_and_log.sh b/scripts/test_and_log.sh new file mode 100755 index 00000000..4500826b --- /dev/null +++ b/scripts/test_and_log.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +readonly SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +readonly PROJECT_DIR="$(dirname $SCRIPT_PATH)" + +$SCRIPT_PATH/test.sh $1 2>&1 | tee $PROJECT_DIR/flutter_driver_tests.log + +kill $(jobs -p) \ No newline at end of file