getScrollX method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'View.getScrollX', apiUrl: 'https://developer.android.com/reference/android/view/View#getScrollX()'), IOSPlatform(apiName: 'UIScrollView.contentOffset', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset'), MacOSPlatform(note: 'This method is implemented using JavaScript.'), LinuxPlatform(), WebPlatform(apiName: 'Window.scrollX', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX'), WindowsPlatform(note: 'This method is implemented using JavaScript.')])
Returns the scrolled left position of the current WebView.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - View.getScrollX)
- iOS WKWebView (Official API - UIScrollView.contentOffset)
- macOS WKWebView:
- This method is implemented using JavaScript.
- Linux WPE WebKit
- Web <iframe> but requires same origin (Official API - Window.scrollX)
- 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: 'View.getScrollX',
apiUrl:
'https://developer.android.com/reference/android/view/View#getScrollX()',
),
IOSPlatform(
apiName: 'UIScrollView.contentOffset',
apiUrl:
'https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset',
),
MacOSPlatform(note: 'This method is implemented using JavaScript.'),
LinuxPlatform(),
WebPlatform(
apiName: 'Window.scrollX',
apiUrl:
'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX',
),
WindowsPlatform(note: 'This method is implemented using JavaScript.'),
],
)
Future<int?> getScrollX() {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.getScrollX.name} is not implemented on the current platform',
);
}