getContentHeight method

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

Gets the height of the HTML content.

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?> getContentHeight() async {
  Map<String, dynamic> args = <String, dynamic>{};
  var height = await channel?.invokeMethod('getContentHeight', args);
  if (height == null || height == 0) {
    // try to use javascript
    var scrollHeight = await evaluateJavascript(
        source: "document.documentElement.scrollHeight;");
    if (scrollHeight != null && scrollHeight is num) {
      height = scrollHeight.toInt();
    }
  }
  return height;
}