scrollTo method

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'View.scrollTo', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#scrollTo(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.scrollTo', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo'), WindowsPlatform(note: 'This method is implemented using JavaScript.')])
Future<void> scrollTo({
  1. required int x,
  2. required int y,
  3. bool animated = false,
})

Scrolls the WebView to the position.

x represents the x position to scroll to.

y represents the y position to scroll to.

animated true to animate the scroll transition, false to make the scoll transition immediate.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • x: all platforms
  • y: all platforms
  • animated: all platforms

Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'View.scrollTo',
      apiUrl:
          'https://developer.android.com/reference/android/webkit/WebView#scrollTo(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.scrollTo',
      apiUrl:
          'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo',
    ),
    WindowsPlatform(note: 'This method is implemented using JavaScript.'),
  ],
)
Future<void> scrollTo({
  required int x,
  required int y,
  bool animated = false,
}) {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.scrollTo.name} is not implemented on the current platform',
  );
}