Skip to content

Commit

Permalink
Adds support to track scroll position changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheVinhLuong committed Nov 19, 2023
1 parent 2e010d8 commit b243d07
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.

## 2.7.0

* Adds support to track scroll position changes. See `PlatformWebViewController.setOnScrollPositionChange`.

## 2.6.0

* Adds support to register a callback to intercept messages that are written to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ abstract class PlatformWebViewController extends PlatformInterface {
'setOnConsoleMessage is not implemented on the current platform',
);
}

/// Sets the listener for content offset changes.
Future<void> setOnScrollPositionChange(
void Function(ScrollPositionChange scrollPositionChange)?
onScrollPositionChange) {
throw UnimplementedError(
'setOnScrollPositionChange is not implemented on the current platform');
}
}

/// Describes the parameters necessary for registering a JavaScript channel.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Defines the parameters of the scroll position change callback.
class ScrollPositionChange {
/// Creates a [ScrollPositionChange].
const ScrollPositionChange(this.x, this.y);

/// The value of the horizontal offset with the origin being at the leftmost
/// of the `WebView`.
final double x;

/// The value of the vertical offset with the origin being at the topmost of
/// the `WebView`.
final double y;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export 'platform_webview_controller_creation_params.dart';
export 'platform_webview_cookie_manager_creation_params.dart';
export 'platform_webview_permission_request.dart';
export 'platform_webview_widget_creation_params.dart';
export 'scroll_position_change.dart';
export 'url_change.dart';
export 'web_resource_error.dart';
export 'webview_cookie.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/webview_flutt
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview_flutter%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.6.0
version: 2.7.0

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down

0 comments on commit b243d07

Please sign in to comment.