scrollBy method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'View.scrollBy', apiUrl: 'https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)'), IOSPlatform(apiName: 'UIScrollView.setContentOffset', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset'), MacOSPlatform(note: 'This method is implemented using JavaScript.'), LinuxPlatform(), WebPlatform(apiName: 'Window.scrollBy', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy'), WindowsPlatform(note: 'This method is implemented using JavaScript.')])
Moves the scrolled position of the WebView.
x represents the amount of pixels to scroll by horizontally.
y represents the amount of pixels to scroll by vertically.
animated true to animate the scroll transition, false to make the scoll transition immediate.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - View.scrollBy)
- iOS WKWebView (Official API - UIScrollView.setContentOffset)
- macOS WKWebView:
- This method is implemented using JavaScript.
- Linux WPE WebKit
- Web <iframe> but requires same origin (Official API - Window.scrollBy)
- Windows WebView2:
- This method is implemented using JavaScript.
Parameters - Officially Supported Platforms/Implementations:
x: all platformsy: all platformsanimated: all platforms
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'View.scrollBy',
apiUrl:
'https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)',
),
IOSPlatform(
apiName: 'UIScrollView.setContentOffset',
apiUrl:
'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset',
),
MacOSPlatform(note: 'This method is implemented using JavaScript.'),
LinuxPlatform(),
WebPlatform(
apiName: 'Window.scrollBy',
apiUrl:
'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy',
),
WindowsPlatform(note: 'This method is implemented using JavaScript.'),
],
)
Future<void> scrollBy({
required int x,
required int y,
bool animated = false,
}) {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.scrollBy.name} is not implemented on the current platform',
);
}