diff --git a/.gitignore b/.gitignore index cac255942..7710a3b56 100755 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,7 @@ # Flutter/Dart/Pub related # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. /pubspec.lock -**/doc/api/ +doc/api/ .dart_tool/ .packages build/ diff --git a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart index 9cb3da6df..2e9a114f6 100644 --- a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart +++ b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart @@ -64,7 +64,8 @@ class InAppWebViewWebElement implements Disposable { } }); - jsWebView = flutterInAppWebView?.createFlutterInAppWebView(_viewId, iframe, iframeContainer); + jsWebView = flutterInAppWebView?.createFlutterInAppWebView( + _viewId, iframe, iframeContainer); } /// Handles method calls over the MethodChannel of this plugin. @@ -206,7 +207,8 @@ class InAppWebViewWebElement implements Disposable { initialData = webView.initialData; initialFile = webView.initialFile; - jsWebView = flutterInAppWebView?.createFlutterInAppWebView(_viewId, iframe, iframeContainer); + jsWebView = flutterInAppWebView?.createFlutterInAppWebView( + _viewId, iframe, iframeContainer); } } } @@ -273,8 +275,7 @@ class InAppWebViewWebElement implements Disposable { String _convertHttpResponseToData(XMLHttpRequest httpRequest) { final String contentType = httpRequest.getResponseHeader('content-type') ?? 'text/html'; - return 'data:$contentType,' + - Uri.encodeComponent(httpRequest.responseText); + return 'data:$contentType,' + Uri.encodeComponent(httpRequest.responseText); } String getIFrameId() { @@ -355,7 +356,8 @@ class InAppWebViewWebElement implements Disposable { Future injectJavascriptFileFromUrl( {required String urlFile, Map? scriptHtmlTagAttributes}) async { - jsWebView?.injectJavascriptFileFromUrl(urlFile.toJS, scriptHtmlTagAttributes?.jsify()); + jsWebView?.injectJavascriptFileFromUrl( + urlFile.toJS, scriptHtmlTagAttributes?.jsify()); } Future injectCSSCode({required String source}) async { @@ -365,7 +367,8 @@ class InAppWebViewWebElement implements Disposable { Future injectCSSFileFromUrl( {required String urlFile, Map? cssLinkHtmlTagAttributes}) async { - jsWebView?.injectCSSFileFromUrl(urlFile.toJS, cssLinkHtmlTagAttributes?.jsify()); + jsWebView?.injectCSSFileFromUrl( + urlFile.toJS, cssLinkHtmlTagAttributes?.jsify()); } Future scrollTo( @@ -458,7 +461,8 @@ class InAppWebViewWebElement implements Disposable { iframe.allowFullscreen = newSettings.iframeAllowFullscreen ?? false; } if (settings!.iframeReferrerPolicy != newSettings.iframeReferrerPolicy) { - iframe.referrerPolicy = newSettings.iframeReferrerPolicy?.toNativeValue() ?? ''; + iframe.referrerPolicy = + newSettings.iframeReferrerPolicy?.toNativeValue() ?? ''; } if (settings!.iframeName != newSettings.iframeName) { iframe.name = newSettings.iframeName ?? ''; diff --git a/flutter_inappwebview_web/lib/web/js_bridge.dart b/flutter_inappwebview_web/lib/web/js_bridge.dart index 18ce729b0..31b0a05ea 100644 --- a/flutter_inappwebview_web/lib/web/js_bridge.dart +++ b/flutter_inappwebview_web/lib/web/js_bridge.dart @@ -21,9 +21,11 @@ extension type JSWebView._(JSObject _) implements JSObject { external void stopLoading(); external JSString? getUrl(); external JSString? getTitle(); - external void injectJavascriptFileFromUrl(JSString urlFile, JSAny? scriptHtmlTagAttributes); + external void injectJavascriptFileFromUrl( + JSString urlFile, JSAny? scriptHtmlTagAttributes); external void injectCSSCode(JSString source); - external void injectCSSFileFromUrl(JSString urlFile, JSAny? cssLinkHtmlTagAttributes); + external void injectCSSFileFromUrl( + JSString urlFile, JSAny? cssLinkHtmlTagAttributes); external void scrollTo(JSNumber x, JSNumber y, JSBoolean animated); external void scrollBy(JSNumber x, JSNumber y, JSBoolean animated); external void printCurrentPage(); @@ -43,8 +45,10 @@ external FlutterInAppWebViewBridge? get flutterInAppWebView; extension type FlutterInAppWebViewBridge._(JSObject _) implements JSObject { external JSObject webViews; - external JSWebView createFlutterInAppWebView(JSAny viewId, HTMLIFrameElement iframe, HTMLDivElement iframeContainer); + external JSWebView createFlutterInAppWebView( + JSAny viewId, HTMLIFrameElement iframe, HTMLDivElement iframeContainer); external JSString getCookieExpirationDate(num timestamp); + /// Allows assigning a function to be callable from `window.flutter_inappwebview.nativeCommunication()` external JSFunction nativeCommunication; } diff --git a/flutter_inappwebview_web/lib/web/web_platform.dart b/flutter_inappwebview_web/lib/web/web_platform.dart index a2c5293e5..5e51c262d 100644 --- a/flutter_inappwebview_web/lib/web/web_platform.dart +++ b/flutter_inappwebview_web/lib/web/web_platform.dart @@ -33,9 +33,9 @@ class InAppWebViewFlutterPlugin { final platformUtil = PlatformUtil(messenger: registrar); // ignore: unused_local_variable final headlessManager = HeadlessInAppWebViewManager(messenger: registrar); - flutterInAppWebView?.nativeCommunication = ( - (String method, JSAny viewId, [JSArray? args]) => _dartNativeCommunication(method, viewId, args?.toDart).toJS - ).toJS; + flutterInAppWebView?.nativeCommunication = ((String method, JSAny viewId, + [JSArray? args]) => + _dartNativeCommunication(method, viewId, args?.toDart).toJS).toJS; } } @@ -73,7 +73,8 @@ Future _dartNativeCommunication(String method, dynamic viewId, String? target = args[2]; String? windowFeatures = args[3]; return (await webViewHtmlElement.onCreateWindow( - windowId, url, target, windowFeatures))?.toJS; + windowId, url, target, windowFeatures)) + ?.toJS; case 'onWindowFocus': webViewHtmlElement.onWindowFocus(); break; diff --git a/package.json b/package.json index 2ab7072ee..e599b2d54 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,14 @@ }, "private": true, "scripts": { - "build": "flutter pub run build_runner build --delete-conflicting-outputs", - "watch": "flutter pub run build_runner watch --delete-conflicting-outputs", - "publish:dry": "flutter pub publish --dry-run", - "publish": "flutter pub publish", - "format": "dart format flutter_inappwebview/lib flutter_inappwebview/example/integration_test flutter_inappwebview_platform_interface/lib flutter_inappwebview_android/lib flutter_inappwebview_ios/lib flutter_inappwebview_macos/lib flutter_inappwebview_web/lib flutter_inappwebview_windows/lib", - "build:publish": "npm run format && npm run build && flutter pub publish", - "docs:gen": "flutter pub global activate dartdoc && flutter pub global run dartdoc:dartdoc", - "docs:serve": "flutter pub global activate dhttpd && flutter pub global run dhttpd:dhttpd --path doc/api" + "build": ".fvm/flutter_sdk/bin/flutter pub run build_runner build --delete-conflicting-outputs", + "watch": ".fvm/flutter_sdk/bin/flutter pub run build_runner watch --delete-conflicting-outputs", + "publish:dry": ".fvm/flutter_sdk/bin/flutter pub publish --dry-run", + "publish": ".fvm/flutter_sdk/bin/flutter pub publish", + "format": ".fvm/flutter_sdk/bin/dart format flutter_inappwebview/lib flutter_inappwebview/example/integration_test flutter_inappwebview_platform_interface/lib flutter_inappwebview_android/lib flutter_inappwebview_ios/lib flutter_inappwebview_macos/lib flutter_inappwebview_web/lib flutter_inappwebview_windows/lib", + "build:publish": "npm run format && npm run build && .fvm/flutter_sdk/bin/flutter pub publish", + "docs:gen": ".fvm/flutter_sdk/bin/dart doc", + "docs:serve": ".fvm/flutter_sdk/bin/flutter pub global activate dhttpd && .fvm/flutter_sdk/bin/flutter pub global run dhttpd:dhttpd --path doc/api" }, "repository": { "type": "git",