Skip to content

Commit ed1672a

Browse files
bparrishMinesFMorschel
authored andcommitted
[webview_flutter_platform_interface] Adds support to set whether to draw the scrollbar (flutter#9125)
Part of flutter/flutter#62464 Platform interface portion for flutter#9024 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 46555a8 commit ed1672a

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.12.0
2+
3+
* Adds support to set whether to draw the scrollbar. See
4+
`PlatformWebViewController.setVerticalScrollBarEnabled`,
5+
`PlatformWebViewController.setHorizontalScrollBarEnabled`,
6+
`PlatformWebViewController.supportsSetScrollBarsEnabled`.
7+
18
## 2.11.0
29

310
* Adds support to set the over-scroll mode for the WebView. See `PlatformWebViewController.setOverScrollMode`.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,26 @@ abstract class PlatformWebViewController extends PlatformInterface {
229229
'scrollBy is not implemented on the current platform');
230230
}
231231

232+
/// Whether the vertical scrollbar should be drawn or not.
233+
Future<void> setVerticalScrollBarEnabled(bool enabled) {
234+
throw UnimplementedError(
235+
'setVerticalScrollBarEnabled is not implemented on the current platform');
236+
}
237+
238+
/// Whether the horizontal scrollbar should be drawn or not.
239+
Future<void> setHorizontalScrollBarEnabled(bool enabled) {
240+
throw UnimplementedError(
241+
'setHorizontalScrollBarEnabled is not implemented on the current platform');
242+
}
243+
244+
/// Returns true if the current platform supports setting whether scrollbars
245+
/// should be drawn or not.
246+
///
247+
/// See [setVerticalScrollBarEnabled] and [setHorizontalScrollBarEnabled].
248+
bool supportsSetScrollBarsEnabled() {
249+
return false;
250+
}
251+
232252
/// Return the current scroll position of this view.
233253
///
234254
/// Scroll position is measured from the top left.

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.11.0
7+
version: 2.12.0
88

99
environment:
1010
sdk: ^3.4.0

packages/webview_flutter/webview_flutter_platform_interface/test/platform_webview_controller_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,41 @@ void main() {
311311
);
312312
});
313313

314+
test(
315+
'Default implementation of setVerticalScrollBarEnabled should throw unimplemented error',
316+
() {
317+
final PlatformWebViewController controller =
318+
ExtendsPlatformWebViewController(
319+
const PlatformWebViewControllerCreationParams());
320+
321+
expect(
322+
() => controller.setVerticalScrollBarEnabled(false),
323+
throwsUnimplementedError,
324+
);
325+
});
326+
327+
test(
328+
'Default implementation of setHorizontalScrollBarEnabled should throw unimplemented error',
329+
() {
330+
final PlatformWebViewController controller =
331+
ExtendsPlatformWebViewController(
332+
const PlatformWebViewControllerCreationParams());
333+
334+
expect(
335+
() => controller.setHorizontalScrollBarEnabled(false),
336+
throwsUnimplementedError,
337+
);
338+
});
339+
340+
test('Default implementation of supportsSetScrollBarsEnabled returns false',
341+
() {
342+
final PlatformWebViewController controller =
343+
ExtendsPlatformWebViewController(
344+
const PlatformWebViewControllerCreationParams());
345+
346+
expect(controller.supportsSetScrollBarsEnabled(), isFalse);
347+
});
348+
314349
test(
315350
'Default implementation of getScrollPosition should throw unimplemented error',
316351
() {

0 commit comments

Comments
 (0)