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();