Skip to content

Commit e44d948

Browse files
committed
Adds support to track scroll position changes
1 parent a20fc3a commit e44d948

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.8.0
2+
3+
* Adds support to track scroll position changes. See `PlatformWebViewController.setOnScrollPositionChange`.
4+
15
## 2.7.0
26

37
* Adds support for handling HTTP basic authentication requests. See `PlatformNavigationDelegate.setOnHttpAuthRequest`.

packages/webview_flutter/webview_flutter_platform_interface/lib/src/platform_webview_controller.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,14 @@ abstract class PlatformWebViewController extends PlatformInterface {
286286
'setOnConsoleMessage is not implemented on the current platform',
287287
);
288288
}
289+
290+
/// Sets the listener for content offset changes.
291+
Future<void> setOnScrollPositionChange(
292+
void Function(ScrollPositionChange scrollPositionChange)?
293+
onScrollPositionChange) {
294+
throw UnimplementedError(
295+
'setOnScrollPositionChange is not implemented on the current platform');
296+
}
289297
}
290298

291299
/// Describes the parameters necessary for registering a JavaScript channel.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/// Defines the parameters of the scroll position change callback.
6+
class ScrollPositionChange {
7+
/// Creates a [ScrollPositionChange].
8+
const ScrollPositionChange(this.x, this.y);
9+
10+
/// The value of the horizontal offset with the origin being at the leftmost
11+
/// of the `WebView`.
12+
final double x;
13+
14+
/// The value of the vertical offset with the origin being at the topmost of
15+
/// the `WebView`.
16+
final double y;
17+
}

packages/webview_flutter/webview_flutter_platform_interface/lib/src/types/types.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export 'platform_webview_controller_creation_params.dart';
1616
export 'platform_webview_cookie_manager_creation_params.dart';
1717
export 'platform_webview_permission_request.dart';
1818
export 'platform_webview_widget_creation_params.dart';
19+
export 'scroll_position_change.dart';
1920
export 'url_change.dart';
2021
export 'web_resource_error.dart';
2122
export 'webview_cookie.dart';

packages/webview_flutter/webview_flutter_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/webview_flutt
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview_flutter%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.7.0
7+
version: 2.8.0
88

99
environment:
1010
sdk: ">=3.0.0 <4.0.0"

0 commit comments

Comments
 (0)