From babbfa16ebdf07aaa9516c55e56a7e8f4b117954 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Tue, 30 Mar 2021 18:34:49 +0200 Subject: [PATCH] improved HeadlessInAppWebView setSize and getSize docs --- lib/src/in_app_webview/headless_in_app_webview.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 8b3fccf9..f19b5152 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -179,15 +179,27 @@ class HeadlessInAppWebView implements WebView { ///Set `-1` to match the corresponding width or height of the current device screen size. ///`Size(-1, -1)` will match both width and height of the current device screen size. /// + ///Note that if the [HeadlessInAppWebView] is not running, this method won't have effect. + /// ///**NOTE for Android**: `Size` width and height values will be converted to `int` values because they cannot have `double` values. Future setSize(Size size) async { + if (!_running) { + return; + } + Map args = {}; args.putIfAbsent('size', () => size.toMap()); await _channel.invokeMethod('setSize', args); } ///Gets the current size in pixels of the WebView. + /// + ///Note that if the [HeadlessInAppWebView] is not running, this method will return `null`. Future getSize() async { + if (!_running) { + return null; + } + Map args = {}; Map sizeMap = (await _channel.invokeMethod('getSize', args))?.cast();