getScrollY method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'View.getScrollY', apiUrl: 'https://developer.android.com/reference/android/view/View#getScrollY()'), 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.scrollY', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY'), WindowsPlatform(note: 'This method is implemented using JavaScript.')])
Returns the scrolled top position of the current WebView.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - View.getScrollY)
- 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.scrollY)
- 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.getScrollY',
apiUrl:
'https://developer.android.com/reference/android/view/View#getScrollY()',
),
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.scrollY',
apiUrl:
'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY',
),
WindowsPlatform(note: 'This method is implemented using JavaScript.'),
],
)
Future<int?> getScrollY() {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.getScrollY.name} is not implemented on the current platform',
);
}