setSize method

  1. @override
Future<void> setSize(
  1. Size size
)

Set the size of the WebView in pixels.

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 PlatformHeadlessInAppWebView 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.

Officially Supported Platforms/Implementations:

  • Android native WebView
  • iOS
  • Web
  • MacOS

Implementation

@override
Future<void> setSize(Size size) async {
  if (!_running) {
    return;
  }

  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('size', () => size.toMap());
  await channel?.invokeMethod('setSize', args);
}