getContentWidth method

  1. @override
Future<int?> getContentWidth()

Gets the width of the HTML content.

NOTE for Android: it is implemented using JavaScript.

NOTE for Web: this method will have effect only if the iframe has the same origin.

NOTE for MacOS: it is implemented using JavaScript.

Officially Supported Platforms/Implementations:

Implementation

@override
Future<int?> getContentWidth() async {
  Map<String, dynamic> args = <String, dynamic>{};
  var height = await channel?.invokeMethod('getContentWidth', args);
  if (height == null || height == 0) {
    // try to use javascript
    var scrollHeight = await evaluateJavascript(
        source: "document.documentElement.scrollWidth;");
    if (scrollHeight != null && scrollHeight is num) {
      height = scrollHeight.toInt();
    }
  }
  return height;
}