getContentHeight method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebView.getContentHeight', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#getContentHeight()'), IOSPlatform(apiName: 'UIScrollView.contentSize', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize'), MacOSPlatform(note: 'This method is implemented using JavaScript.'), WebPlatform(apiName: 'Document.documentElement.scrollHeight', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight'), LinuxPlatform(), WindowsPlatform(note: 'This method is implemented using JavaScript.')])
Gets the height of the HTML content.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebView.getContentHeight)
- iOS WKWebView (Official API - UIScrollView.contentSize)
- macOS WKWebView:
- This method is implemented using JavaScript.
- Web <iframe> but requires same origin (Official API - Document.documentElement.scrollHeight)
- Linux WPE WebKit
- Windows WebView2:
- This method is implemented using JavaScript.
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'WebView.getContentHeight',
apiUrl:
'https://developer.android.com/reference/android/webkit/WebView#getContentHeight()',
),
IOSPlatform(
apiName: 'UIScrollView.contentSize',
apiUrl:
'https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize',
),
MacOSPlatform(note: 'This method is implemented using JavaScript.'),
WebPlatform(
apiName: 'Document.documentElement.scrollHeight',
apiUrl:
'https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight',
),
LinuxPlatform(),
WindowsPlatform(note: 'This method is implemented using JavaScript.'),
],
)
Future<int?> getContentHeight() {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.getContentHeight.name} is not implemented on the current platform',
);
}