From d0cfbb55ee769aebb9b2cc95a7ec6b7a2414d9c7 Mon Sep 17 00:00:00 2001 From: Antonino Date: Mon, 18 Feb 2019 21:45:52 +0100 Subject: [PATCH 1/8] Added the ability to activate the zoom --- .../webviewflutter/FlutterWebView.java | 27 +++- .../webview_flutter/example/lib/main.dart | 1 + .../webview_flutter/lib/webview_flutter.dart | 144 +++++++++--------- 3 files changed, 96 insertions(+), 76 deletions(-) diff --git a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java index 1ff869b04c61..94296f9e3ac0 100644 --- a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java +++ b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java @@ -137,13 +137,13 @@ private void evaluateJavaScript(MethodCall methodCall, final Result result) { throw new UnsupportedOperationException("JavaScript string cannot be null"); } webView.evaluateJavascript( - jsString, - new android.webkit.ValueCallback() { - @Override - public void onReceiveValue(String value) { - result.success(value); - } - }); + jsString, + new android.webkit.ValueCallback() { + @Override + public void onReceiveValue(String value) { + result.success(value); + } + }); } @SuppressWarnings("unchecked") @@ -174,6 +174,9 @@ private void applySettings(Map settings) { case "jsMode": updateJsMode((Integer) settings.get(key)); break; + case "zoom": + updateZoomMode((boolean) settings.get(key)); + break; default: throw new IllegalArgumentException("Unknown WebView setting: " + key); } @@ -193,10 +196,18 @@ private void updateJsMode(int mode) { } } + private void updateZoomMode(boolean mode) { + //webView.getSettings().setLoadWithOverviewMode(true); + webView.getSettings().setUseWideViewPort(mode); + webView.getSettings().setBuiltInZoomControls(mode); + // Pop-up zoom controls disabled. This is a temporary stop because dialog is not responding to touch events. + webView.getSettings().setDisplayZoomControls(false); + } + private void registerJavaScriptChannelNames(List channelNames) { for (String channelName : channelNames) { webView.addJavascriptInterface( - new JavaScriptChannel(methodChannel, channelName), channelName); + new JavaScriptChannel(methodChannel, channelName), channelName); } } diff --git a/packages/webview_flutter/example/lib/main.dart b/packages/webview_flutter/example/lib/main.dart index 4e3fe6cbdbdd..efe24264f787 100644 --- a/packages/webview_flutter/example/lib/main.dart +++ b/packages/webview_flutter/example/lib/main.dart @@ -28,6 +28,7 @@ class WebViewExample extends StatelessWidget { body: Builder(builder: (BuildContext context) { return WebView( initialUrl: 'https://flutter.io', + zoom: true, javascriptMode: JavascriptMode.unrestricted, onWebViewCreated: (WebViewController webViewController) { _controller.complete(webViewController); diff --git a/packages/webview_flutter/lib/webview_flutter.dart b/packages/webview_flutter/lib/webview_flutter.dart index a4bb285a2d8d..399c3a363ad2 100644 --- a/packages/webview_flutter/lib/webview_flutter.dart +++ b/packages/webview_flutter/lib/webview_flutter.dart @@ -14,7 +14,7 @@ typedef void WebViewCreatedCallback(WebViewController controller); enum JavascriptMode { /// JavaScript execution is disabled. disabled, - + /// JavaScript execution is not restricted. unrestricted, } @@ -25,7 +25,7 @@ class JavascriptMessage { /// /// The `message` parameter must not be null. const JavascriptMessage(this.message) : assert(message != null); - + /// The contents of the message that was sent by the JavaScript code. final String message; } @@ -41,12 +41,12 @@ class JavascriptChannel { /// /// The parameters `name` and `onMessageReceived` must not be null. JavascriptChannel({ - @required this.name, - @required this.onMessageReceived, - }) : assert(name != null), + @required this.name, + @required this.onMessageReceived, + }) : assert(name != null), assert(onMessageReceived != null), assert(_validChannelNames.hasMatch(name)); - + /// The channel's name. /// /// Passing this channel object as part of a [WebView.javascriptChannels] adds a channel object to @@ -59,7 +59,7 @@ class JavascriptChannel { /// /// See also [WebView.javascriptChannels] for more details on the channel registration mechanism. final String name; - + /// A callback that's invoked when a message is received through the channel. final JavascriptMessageHandler onMessageReceived; } @@ -73,18 +73,19 @@ class WebView extends StatefulWidget { /// /// The `javascriptMode` parameter must not be null. const WebView({ - Key key, - this.onWebViewCreated, - this.initialUrl, - this.javascriptMode = JavascriptMode.disabled, - this.javascriptChannels, - this.gestureRecognizers, - }) : assert(javascriptMode != null), + Key key, + this.onWebViewCreated, + this.initialUrl, + this.javascriptMode = JavascriptMode.disabled, + this.javascriptChannels, + this.gestureRecognizers, + this.zoom = false, + }) : assert(javascriptMode != null), super(key: key); - + /// If not null invoked once the web view is created. final WebViewCreatedCallback onWebViewCreated; - + /// Which gestures should be consumed by the web view. /// /// It is possible for other gesture recognizers to be competing with the web view on pointer @@ -95,13 +96,13 @@ class WebView extends StatefulWidget { /// When this set is empty or null, the web view will only handle pointer events for gestures that /// were not claimed by any other gesture recognizer. final Set> gestureRecognizers; - + /// The initial URL to load. final String initialUrl; - + /// Whether Javascript execution is enabled. final JavascriptMode javascriptMode; - + /// The set of [JavascriptChannel]s available to JavaScript code running in the web view. /// /// For each [JavascriptChannel] in the set, a channel object is made available for the @@ -130,17 +131,20 @@ class WebView extends StatefulWidget { /// /// A null value is equivalent to an empty set. final Set javascriptChannels; - + + /// Enable/Disable zoom. + final bool zoom; + @override State createState() => _WebViewState(); } class _WebViewState extends State { final Completer _controller = - Completer(); - + Completer(); + _WebSettings _settings; - + @override Widget build(BuildContext context) { if (defaultTargetPlatform == TargetPlatform.android) { @@ -177,27 +181,27 @@ class _WebViewState extends State { return Text( '$defaultTargetPlatform is not yet supported by the webview_flutter plugin'); } - + @override void initState() { super.initState(); _assertJavascriptChannelNamesAreUnique(); } - + @override void didUpdateWidget(WebView oldWidget) { super.didUpdateWidget(oldWidget); _assertJavascriptChannelNamesAreUnique(); _updateConfiguration(_WebSettings.fromWidget(widget)); } - + Future _updateConfiguration(_WebSettings settings) async { _settings = settings; final WebViewController controller = await _controller.future; controller._updateSettings(settings); controller._updateJavascriptChannels(widget.javascriptChannels); } - + void _onPlatformViewCreated(int id) { final WebViewController controller = WebViewController._( id, @@ -209,7 +213,7 @@ class _WebViewState extends State { widget.onWebViewCreated(controller); } } - + void _assertJavascriptChannelNamesAreUnique() { if (widget.javascriptChannels == null || widget.javascriptChannels.isEmpty) { @@ -230,22 +234,22 @@ Set _extractChannelNames(Set channels) { class _CreationParams { _CreationParams( {this.initialUrl, this.settings, this.javascriptChannelNames}); - + static _CreationParams fromWidget(WebView widget) { return _CreationParams( initialUrl: widget.initialUrl, settings: _WebSettings.fromWidget(widget), javascriptChannelNames: - _extractChannelNames(widget.javascriptChannels).toList(), + _extractChannelNames(widget.javascriptChannels).toList(), ); } - + final String initialUrl; - + final _WebSettings settings; - + final List javascriptChannelNames; - + Map toMap() { return { 'initialUrl': initialUrl, @@ -257,27 +261,31 @@ class _CreationParams { class _WebSettings { _WebSettings({ - this.javascriptMode, - }); - + this.javascriptMode, + this.zoom + }); + static _WebSettings fromWidget(WebView widget) { - return _WebSettings(javascriptMode: widget.javascriptMode); + return _WebSettings(javascriptMode: widget.javascriptMode, zoom: widget.zoom); } - + final JavascriptMode javascriptMode; - + final bool zoom; + Map toMap() { return { 'jsMode': javascriptMode.index, + 'zoom': zoom, }; } - + Map updatesMap(_WebSettings newSettings) { if (javascriptMode == newSettings.javascriptMode) { return null; } return { 'jsMode': newSettings.javascriptMode.index, + 'zoom': newSettings.zoom, }; } } @@ -293,15 +301,15 @@ class WebViewController { _updateJavascriptChannelsFromSet(javascriptChannels); _channel.setMethodCallHandler(_onMethodCall); } - + final MethodChannel _channel; - + _WebSettings _settings; - + // Maps a channel name to a channel. Map _javascriptChannels = - {}; - + {}; + Future _onMethodCall(MethodCall call) async { switch (call.method) { case 'javascriptChannelMessage': @@ -312,7 +320,7 @@ class WebViewController { break; } } - + /// Loads the specified URL. /// /// `url` must not be null. @@ -326,7 +334,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod('loadUrl', url); } - + /// Accessor to the current URL that the WebView is displaying. /// /// If [WebView.initialUrl] was never specified, returns `null`. @@ -341,7 +349,7 @@ class WebViewController { final String url = await _channel.invokeMethod('currentUrl'); return url; } - + /// Checks whether there's a back history item. /// /// Note that this operation is asynchronous, and it is possible that the "canGoBack" state has @@ -353,7 +361,7 @@ class WebViewController { final bool canGoBack = await _channel.invokeMethod("canGoBack"); return canGoBack; } - + /// Checks whether there's a forward history item. /// /// Note that this operation is asynchronous, and it is possible that the "canGoForward" state has @@ -365,7 +373,7 @@ class WebViewController { final bool canGoForward = await _channel.invokeMethod("canGoForward"); return canGoForward; } - + /// Goes back in the history of this WebView. /// /// If there is no back history item this is a no-op. @@ -375,7 +383,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod("goBack"); } - + /// Goes forward in the history of this WebView. /// /// If there is no forward history item this is a no-op. @@ -385,7 +393,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod("goForward"); } - + /// Reloads the current URL. Future reload() async { // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter. @@ -393,7 +401,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod("reload"); } - + /// Clears all caches used by the [WebView]. /// /// The following caches are cleared: @@ -411,7 +419,7 @@ class WebViewController { await _channel.invokeMethod("clearCache"); return reload(); } - + Future _updateSettings(_WebSettings setting) async { final Map updateMap = _settings.updatesMap(setting); if (updateMap == null) { @@ -423,15 +431,15 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod('updateSettings', updateMap); } - + Future _updateJavascriptChannels( Set newChannels) async { final Set currentChannels = _javascriptChannels.keys.toSet(); final Set newChannelNames = _extractChannelNames(newChannels); final Set channelsToAdd = - newChannelNames.difference(currentChannels); + newChannelNames.difference(currentChannels); final Set channelsToRemove = - currentChannels.difference(newChannelNames); + currentChannels.difference(newChannelNames); if (channelsToRemove.isNotEmpty) { // TODO(amirh): remove this when the invokeMethod update makes it to stable Flutter. // https://github.com/flutter/flutter/issues/26431 @@ -447,7 +455,7 @@ class WebViewController { } _updateJavascriptChannelsFromSet(newChannels); } - + void _updateJavascriptChannelsFromSet(Set channels) { _javascriptChannels.clear(); if (channels == null) { @@ -457,7 +465,7 @@ class WebViewController { _javascriptChannels[channel.name] = channel; } } - + /// Evaluates a JavaScript expression in the context of the current page. /// /// On Android returns the evaluation result as a JSON formatted string. @@ -482,7 +490,7 @@ class WebViewController { // https://github.com/flutter/flutter/issues/26431 // ignore: strong_mode_implicit_dynamic_method final String result = - await _channel.invokeMethod('evaluateJavascript', javascriptString); + await _channel.invokeMethod('evaluateJavascript', javascriptString); return result; } } @@ -493,22 +501,22 @@ class CookieManager { factory CookieManager() { return _instance ??= CookieManager._(); } - + CookieManager._(); - + static const MethodChannel _channel = - MethodChannel('plugins.flutter.io/cookie_manager'); + MethodChannel('plugins.flutter.io/cookie_manager'); static CookieManager _instance; - + /// Clears all cookies. /// /// This is supported for >= IOS 9. /// /// Returns true if cookies were present before clearing, else false. Future clearCookies() => _channel - // TODO(amirh): remove this when the invokeMethod update makes it to stable Flutter. - // https://github.com/flutter/flutter/issues/26431 - // ignore: strong_mode_implicit_dynamic_method + // TODO(amirh): remove this when the invokeMethod update makes it to stable Flutter. + // https://github.com/flutter/flutter/issues/26431 + // ignore: strong_mode_implicit_dynamic_method .invokeMethod('clearCookies') .then((dynamic result) => result); } From 619434a87a9e7ba3ff5ae5311b11d6d63102c896 Mon Sep 17 00:00:00 2001 From: Antonino Date: Mon, 18 Feb 2019 22:24:35 +0100 Subject: [PATCH 2/8] Added the ability to activate the zoom --- packages/webview_flutter/res/values/strings_en.arb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 packages/webview_flutter/res/values/strings_en.arb diff --git a/packages/webview_flutter/res/values/strings_en.arb b/packages/webview_flutter/res/values/strings_en.arb new file mode 100644 index 000000000000..e69de29bb2d1 From 03469293e81eda457f65ec90305d81ec4669473a Mon Sep 17 00:00:00 2001 From: Antonino Di Natale Date: Thu, 21 Feb 2019 01:16:07 +0100 Subject: [PATCH 3/8] update format --- .../plugins/webviewflutter/FlutterWebView.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java index 94296f9e3ac0..70992a4b9600 100644 --- a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java +++ b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java @@ -137,13 +137,13 @@ private void evaluateJavaScript(MethodCall methodCall, final Result result) { throw new UnsupportedOperationException("JavaScript string cannot be null"); } webView.evaluateJavascript( - jsString, - new android.webkit.ValueCallback() { - @Override - public void onReceiveValue(String value) { - result.success(value); - } - }); + jsString, + new android.webkit.ValueCallback() { + @Override + public void onReceiveValue(String value) { + result.success(value); + } + }); } @SuppressWarnings("unchecked") @@ -207,7 +207,7 @@ private void updateZoomMode(boolean mode) { private void registerJavaScriptChannelNames(List channelNames) { for (String channelName : channelNames) { webView.addJavascriptInterface( - new JavaScriptChannel(methodChannel, channelName), channelName); + new JavaScriptChannel(methodChannel, channelName), channelName); } } From a87b5540f68d0a485511cd0efd5ae44c25055bf3 Mon Sep 17 00:00:00 2001 From: Antonino Di Natale Date: Thu, 21 Feb 2019 01:26:10 +0100 Subject: [PATCH 4/8] update format --- .../webview_flutter/lib/webview_flutter.dart | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/packages/webview_flutter/lib/webview_flutter.dart b/packages/webview_flutter/lib/webview_flutter.dart index 399c3a363ad2..910cdeb1dd83 100644 --- a/packages/webview_flutter/lib/webview_flutter.dart +++ b/packages/webview_flutter/lib/webview_flutter.dart @@ -14,7 +14,7 @@ typedef void WebViewCreatedCallback(WebViewController controller); enum JavascriptMode { /// JavaScript execution is disabled. disabled, - + /// JavaScript execution is not restricted. unrestricted, } @@ -25,7 +25,7 @@ class JavascriptMessage { /// /// The `message` parameter must not be null. const JavascriptMessage(this.message) : assert(message != null); - + /// The contents of the message that was sent by the JavaScript code. final String message; } @@ -41,12 +41,12 @@ class JavascriptChannel { /// /// The parameters `name` and `onMessageReceived` must not be null. JavascriptChannel({ - @required this.name, - @required this.onMessageReceived, - }) : assert(name != null), + @required this.name, + @required this.onMessageReceived, + }) : assert(name != null), assert(onMessageReceived != null), assert(_validChannelNames.hasMatch(name)); - + /// The channel's name. /// /// Passing this channel object as part of a [WebView.javascriptChannels] adds a channel object to @@ -59,7 +59,7 @@ class JavascriptChannel { /// /// See also [WebView.javascriptChannels] for more details on the channel registration mechanism. final String name; - + /// A callback that's invoked when a message is received through the channel. final JavascriptMessageHandler onMessageReceived; } @@ -73,19 +73,19 @@ class WebView extends StatefulWidget { /// /// The `javascriptMode` parameter must not be null. const WebView({ - Key key, - this.onWebViewCreated, - this.initialUrl, - this.javascriptMode = JavascriptMode.disabled, - this.javascriptChannels, - this.gestureRecognizers, - this.zoom = false, - }) : assert(javascriptMode != null), + Key key, + this.onWebViewCreated, + this.initialUrl, + this.javascriptMode = JavascriptMode.disabled, + this.javascriptChannels, + this.gestureRecognizers, + this.zoom = false, + }) : assert(javascriptMode != null), super(key: key); - + /// If not null invoked once the web view is created. final WebViewCreatedCallback onWebViewCreated; - + /// Which gestures should be consumed by the web view. /// /// It is possible for other gesture recognizers to be competing with the web view on pointer @@ -96,13 +96,13 @@ class WebView extends StatefulWidget { /// When this set is empty or null, the web view will only handle pointer events for gestures that /// were not claimed by any other gesture recognizer. final Set> gestureRecognizers; - + /// The initial URL to load. final String initialUrl; - + /// Whether Javascript execution is enabled. final JavascriptMode javascriptMode; - + /// The set of [JavascriptChannel]s available to JavaScript code running in the web view. /// /// For each [JavascriptChannel] in the set, a channel object is made available for the @@ -142,9 +142,9 @@ class WebView extends StatefulWidget { class _WebViewState extends State { final Completer _controller = Completer(); - + _WebSettings _settings; - + @override Widget build(BuildContext context) { if (defaultTargetPlatform == TargetPlatform.android) { @@ -181,27 +181,27 @@ class _WebViewState extends State { return Text( '$defaultTargetPlatform is not yet supported by the webview_flutter plugin'); } - + @override void initState() { super.initState(); _assertJavascriptChannelNamesAreUnique(); } - + @override void didUpdateWidget(WebView oldWidget) { super.didUpdateWidget(oldWidget); _assertJavascriptChannelNamesAreUnique(); _updateConfiguration(_WebSettings.fromWidget(widget)); } - + Future _updateConfiguration(_WebSettings settings) async { _settings = settings; final WebViewController controller = await _controller.future; controller._updateSettings(settings); controller._updateJavascriptChannels(widget.javascriptChannels); } - + void _onPlatformViewCreated(int id) { final WebViewController controller = WebViewController._( id, @@ -213,7 +213,7 @@ class _WebViewState extends State { widget.onWebViewCreated(controller); } } - + void _assertJavascriptChannelNamesAreUnique() { if (widget.javascriptChannels == null || widget.javascriptChannels.isEmpty) { @@ -234,7 +234,7 @@ Set _extractChannelNames(Set channels) { class _CreationParams { _CreationParams( {this.initialUrl, this.settings, this.javascriptChannelNames}); - + static _CreationParams fromWidget(WebView widget) { return _CreationParams( initialUrl: widget.initialUrl, @@ -243,13 +243,13 @@ class _CreationParams { _extractChannelNames(widget.javascriptChannels).toList(), ); } - + final String initialUrl; - + final _WebSettings settings; - + final List javascriptChannelNames; - + Map toMap() { return { 'initialUrl': initialUrl, @@ -261,14 +261,14 @@ class _CreationParams { class _WebSettings { _WebSettings({ - this.javascriptMode, - this.zoom - }); + this.javascriptMode, + this.zoom + }); static _WebSettings fromWidget(WebView widget) { return _WebSettings(javascriptMode: widget.javascriptMode, zoom: widget.zoom); } - + final JavascriptMode javascriptMode; final bool zoom; @@ -278,7 +278,7 @@ class _WebSettings { 'zoom': zoom, }; } - + Map updatesMap(_WebSettings newSettings) { if (javascriptMode == newSettings.javascriptMode) { return null; @@ -301,15 +301,15 @@ class WebViewController { _updateJavascriptChannelsFromSet(javascriptChannels); _channel.setMethodCallHandler(_onMethodCall); } - + final MethodChannel _channel; - + _WebSettings _settings; - + // Maps a channel name to a channel. Map _javascriptChannels = {}; - + Future _onMethodCall(MethodCall call) async { switch (call.method) { case 'javascriptChannelMessage': @@ -320,7 +320,7 @@ class WebViewController { break; } } - + /// Loads the specified URL. /// /// `url` must not be null. @@ -334,7 +334,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod('loadUrl', url); } - + /// Accessor to the current URL that the WebView is displaying. /// /// If [WebView.initialUrl] was never specified, returns `null`. @@ -361,7 +361,7 @@ class WebViewController { final bool canGoBack = await _channel.invokeMethod("canGoBack"); return canGoBack; } - + /// Checks whether there's a forward history item. /// /// Note that this operation is asynchronous, and it is possible that the "canGoForward" state has @@ -373,7 +373,7 @@ class WebViewController { final bool canGoForward = await _channel.invokeMethod("canGoForward"); return canGoForward; } - + /// Goes back in the history of this WebView. /// /// If there is no back history item this is a no-op. @@ -383,7 +383,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod("goBack"); } - + /// Goes forward in the history of this WebView. /// /// If there is no forward history item this is a no-op. @@ -393,7 +393,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod("goForward"); } - + /// Reloads the current URL. Future reload() async { // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter. @@ -401,7 +401,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod("reload"); } - + /// Clears all caches used by the [WebView]. /// /// The following caches are cleared: @@ -419,7 +419,7 @@ class WebViewController { await _channel.invokeMethod("clearCache"); return reload(); } - + Future _updateSettings(_WebSettings setting) async { final Map updateMap = _settings.updatesMap(setting); if (updateMap == null) { @@ -431,7 +431,7 @@ class WebViewController { // ignore: strong_mode_implicit_dynamic_method return _channel.invokeMethod('updateSettings', updateMap); } - + Future _updateJavascriptChannels( Set newChannels) async { final Set currentChannels = _javascriptChannels.keys.toSet(); @@ -455,7 +455,7 @@ class WebViewController { } _updateJavascriptChannelsFromSet(newChannels); } - + void _updateJavascriptChannelsFromSet(Set channels) { _javascriptChannels.clear(); if (channels == null) { @@ -465,7 +465,7 @@ class WebViewController { _javascriptChannels[channel.name] = channel; } } - + /// Evaluates a JavaScript expression in the context of the current page. /// /// On Android returns the evaluation result as a JSON formatted string. @@ -501,22 +501,22 @@ class CookieManager { factory CookieManager() { return _instance ??= CookieManager._(); } - + CookieManager._(); - + static const MethodChannel _channel = - MethodChannel('plugins.flutter.io/cookie_manager'); + MethodChannel('plugins.flutter.io/cookie_manager'); static CookieManager _instance; - + /// Clears all cookies. /// /// This is supported for >= IOS 9. /// /// Returns true if cookies were present before clearing, else false. Future clearCookies() => _channel - // TODO(amirh): remove this when the invokeMethod update makes it to stable Flutter. - // https://github.com/flutter/flutter/issues/26431 - // ignore: strong_mode_implicit_dynamic_method + // TODO(amirh): remove this when the invokeMethod update makes it to stable Flutter. + // https://github.com/flutter/flutter/issues/26431 + // ignore: strong_mode_implicit_dynamic_method .invokeMethod('clearCookies') .then((dynamic result) => result); } From 88f417a7dc5c91bc9ef8030b58ffa1c3edf28dd7 Mon Sep 17 00:00:00 2001 From: Antonino Di Natale Date: Thu, 21 Feb 2019 01:29:22 +0100 Subject: [PATCH 5/8] update format --- .../webview_flutter/lib/webview_flutter.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/webview_flutter/lib/webview_flutter.dart b/packages/webview_flutter/lib/webview_flutter.dart index 910cdeb1dd83..25d449e9abbf 100644 --- a/packages/webview_flutter/lib/webview_flutter.dart +++ b/packages/webview_flutter/lib/webview_flutter.dart @@ -141,7 +141,7 @@ class WebView extends StatefulWidget { class _WebViewState extends State { final Completer _controller = - Completer(); + Completer(); _WebSettings _settings; @@ -240,7 +240,7 @@ class _CreationParams { initialUrl: widget.initialUrl, settings: _WebSettings.fromWidget(widget), javascriptChannelNames: - _extractChannelNames(widget.javascriptChannels).toList(), + _extractChannelNames(widget.javascriptChannels).toList(), ); } @@ -264,7 +264,7 @@ class _WebSettings { this.javascriptMode, this.zoom }); - + static _WebSettings fromWidget(WebView widget) { return _WebSettings(javascriptMode: widget.javascriptMode, zoom: widget.zoom); } @@ -308,7 +308,7 @@ class WebViewController { // Maps a channel name to a channel. Map _javascriptChannels = - {}; + {}; Future _onMethodCall(MethodCall call) async { switch (call.method) { @@ -349,7 +349,7 @@ class WebViewController { final String url = await _channel.invokeMethod('currentUrl'); return url; } - + /// Checks whether there's a back history item. /// /// Note that this operation is asynchronous, and it is possible that the "canGoBack" state has @@ -437,9 +437,9 @@ class WebViewController { final Set currentChannels = _javascriptChannels.keys.toSet(); final Set newChannelNames = _extractChannelNames(newChannels); final Set channelsToAdd = - newChannelNames.difference(currentChannels); + newChannelNames.difference(currentChannels); final Set channelsToRemove = - currentChannels.difference(newChannelNames); + currentChannels.difference(newChannelNames); if (channelsToRemove.isNotEmpty) { // TODO(amirh): remove this when the invokeMethod update makes it to stable Flutter. // https://github.com/flutter/flutter/issues/26431 @@ -490,7 +490,7 @@ class WebViewController { // https://github.com/flutter/flutter/issues/26431 // ignore: strong_mode_implicit_dynamic_method final String result = - await _channel.invokeMethod('evaluateJavascript', javascriptString); + await _channel.invokeMethod('evaluateJavascript', javascriptString); return result; } } From 060a04925bda3107a00f7c1cb0dbdab3d53b9d33 Mon Sep 17 00:00:00 2001 From: Antonino Di Natale Date: Thu, 21 Feb 2019 01:41:02 +0100 Subject: [PATCH 6/8] update format --- packages/webview_flutter/lib/webview_flutter.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/webview_flutter/lib/webview_flutter.dart b/packages/webview_flutter/lib/webview_flutter.dart index 25d449e9abbf..d5df412a30c1 100644 --- a/packages/webview_flutter/lib/webview_flutter.dart +++ b/packages/webview_flutter/lib/webview_flutter.dart @@ -260,13 +260,10 @@ class _CreationParams { } class _WebSettings { - _WebSettings({ - this.javascriptMode, - this.zoom - }); - + _WebSettings({this.javascriptMode,this.zoom}); static _WebSettings fromWidget(WebView widget) { - return _WebSettings(javascriptMode: widget.javascriptMode, zoom: widget.zoom); + return _WebSettings( + javascriptMode: widget.javascriptMode, zoom: widget.zoom); } final JavascriptMode javascriptMode; From a8e3ca9c7730a62a3f49e19ed2db0a523a3f2446 Mon Sep 17 00:00:00 2001 From: Antonino Di Natale Date: Thu, 21 Feb 2019 01:46:43 +0100 Subject: [PATCH 7/8] update format --- packages/webview_flutter/lib/webview_flutter.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/webview_flutter/lib/webview_flutter.dart b/packages/webview_flutter/lib/webview_flutter.dart index d5df412a30c1..d6379c87f257 100644 --- a/packages/webview_flutter/lib/webview_flutter.dart +++ b/packages/webview_flutter/lib/webview_flutter.dart @@ -131,10 +131,10 @@ class WebView extends StatefulWidget { /// /// A null value is equivalent to an empty set. final Set javascriptChannels; - + /// Enable/Disable zoom. final bool zoom; - + @override State createState() => _WebViewState(); } @@ -260,7 +260,7 @@ class _CreationParams { } class _WebSettings { - _WebSettings({this.javascriptMode,this.zoom}); + _WebSettings({this.javascriptMode, this.zoom}); static _WebSettings fromWidget(WebView widget) { return _WebSettings( javascriptMode: widget.javascriptMode, zoom: widget.zoom); @@ -268,7 +268,7 @@ class _WebSettings { final JavascriptMode javascriptMode; final bool zoom; - + Map toMap() { return { 'jsMode': javascriptMode.index, From a8769eb2e1e58b3b8c1f9ba41e86a24429017d72 Mon Sep 17 00:00:00 2001 From: Antonino Di Natale Date: Thu, 21 Feb 2019 01:51:41 +0100 Subject: [PATCH 8/8] update format --- packages/webview_flutter/lib/webview_flutter.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/webview_flutter/lib/webview_flutter.dart b/packages/webview_flutter/lib/webview_flutter.dart index d6379c87f257..f85dbc502041 100644 --- a/packages/webview_flutter/lib/webview_flutter.dart +++ b/packages/webview_flutter/lib/webview_flutter.dart @@ -131,10 +131,10 @@ class WebView extends StatefulWidget { /// /// A null value is equivalent to an empty set. final Set javascriptChannels; - + /// Enable/Disable zoom. final bool zoom; - + @override State createState() => _WebViewState(); } @@ -268,7 +268,7 @@ class _WebSettings { final JavascriptMode javascriptMode; final bool zoom; - + Map toMap() { return { 'jsMode': javascriptMode.index,