Skip to content

[webview_flutter_platform_interface] Adds support to set whether to draw the scrollbar #9125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.12.0

* Adds support to set whether to draw the scrollbar. See
`PlatformWebViewController.setVerticalScrollBarEnabled`,
`PlatformWebViewController.setHorizontalScrollBarEnabled`,
`PlatformWebViewController.supportsSetScrollBarsEnabled`.

## 2.11.0

* Adds support to set the over-scroll mode for the WebView. See `PlatformWebViewController.setOverScrollMode`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,26 @@ abstract class PlatformWebViewController extends PlatformInterface {
'scrollBy is not implemented on the current platform');
}

/// Whether the vertical scrollbar should be drawn or not.
Future<void> setVerticalScrollBarEnabled(bool enabled) {
throw UnimplementedError(
'setVerticalScrollBarEnabled is not implemented on the current platform');
}

/// Whether the horizontal scrollbar should be drawn or not.
Future<void> setHorizontalScrollBarEnabled(bool enabled) {
throw UnimplementedError(
'setHorizontalScrollBarEnabled is not implemented on the current platform');
}

/// Returns true if the current platform supports setting whether scrollbars
/// should be drawn or not.
///
/// See [setVerticalScrollBarEnabled] and [setHorizontalScrollBarEnabled].
bool supportsSetScrollBarsEnabled() {
return false;
}

/// Return the current scroll position of this view.
///
/// Scroll position is measured from the top left.
Expand Down
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.11.0
version: 2.12.0

environment:
sdk: ^3.4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,41 @@ void main() {
);
});

test(
'Default implementation of setVerticalScrollBarEnabled should throw unimplemented error',
() {
final PlatformWebViewController controller =
ExtendsPlatformWebViewController(
const PlatformWebViewControllerCreationParams());

expect(
() => controller.setVerticalScrollBarEnabled(false),
throwsUnimplementedError,
);
});

test(
'Default implementation of setHorizontalScrollBarEnabled should throw unimplemented error',
() {
final PlatformWebViewController controller =
ExtendsPlatformWebViewController(
const PlatformWebViewControllerCreationParams());

expect(
() => controller.setHorizontalScrollBarEnabled(false),
throwsUnimplementedError,
);
});

test('Default implementation of supportsSetScrollBarsEnabled returns false',
() {
final PlatformWebViewController controller =
ExtendsPlatformWebViewController(
const PlatformWebViewControllerCreationParams());

expect(controller.supportsSetScrollBarsEnabled(), isFalse);
});

test(
'Default implementation of getScrollPosition should throw unimplemented error',
() {
Expand Down