Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
49f57ba
feat: Add scrollBarEnabled function
Nov 27, 2024
1f1ad6f
chore: Modify pubspec for test setup
Nov 27, 2024
4217429
test: Add dart test code
Nov 27, 2024
45abbc1
reset wkwebview
bparrishMines Apr 8, 2025
afd7fc1
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines Apr 8, 2025
d214e1a
undo pubspec changes
bparrishMines Apr 8, 2025
13421ca
proper dependency overrides
bparrishMines Apr 8, 2025
05ab710
update platform interface
bparrishMines Apr 8, 2025
c8387fe
dart side of impl
bparrishMines Apr 8, 2025
8475a1e
java side impl
bparrishMines Apr 8, 2025
7499acd
ios impl
bparrishMines Apr 8, 2025
45f7a89
app facing updated
bparrishMines Apr 8, 2025
5778e9f
formatting
bparrishMines Apr 8, 2025
61de0eb
suppress
bparrishMines Apr 8, 2025
72f9fea
add destroy
bparrishMines Apr 8, 2025
e6d0a5f
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines Apr 18, 2025
ac414de
update generated code
bparrishMines Apr 21, 2025
1bdd7c6
regen mocks
bparrishMines Apr 21, 2025
0f1461e
add destory method
bparrishMines Apr 21, 2025
a6b6286
formatting
bparrishMines Apr 21, 2025
274f10b
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines Apr 21, 2025
b35c5fb
format and add support query
bparrishMines Apr 21, 2025
d9de673
query test platform interface
bparrishMines Apr 21, 2025
cd1b2d7
reeturn value based on platform for wkwebview
bparrishMines Apr 21, 2025
1d52c56
accidental character
bparrishMines Apr 21, 2025
01fb364
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines Apr 21, 2025
61ab32a
docs that i prefer
bparrishMines Apr 21, 2025
a35c481
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines May 13, 2025
a523cae
formatting
bparrishMines May 13, 2025
cb123a5
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines May 14, 2025
b667829
fix pubspecs and changelog
bparrishMines May 14, 2025
518111c
fix pubspecs
bparrishMines May 14, 2025
c88c097
actual fix
bparrishMines May 14, 2025
0ecd78f
and one more file
bparrishMines May 14, 2025
2be1755
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines May 15, 2025
181138b
change to future bool
bparrishMines May 15, 2025
43ba081
Merge branch 'main' of github.com:flutter/packages into webview_scrol…
bparrishMines May 15, 2025
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
8 changes: 6 additions & 2 deletions packages/webview_flutter/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## NEXT
## 4.12.0

* Updates README to indicate that Andoid SDK <21 is no longer supported.
* Adds support to set whether to draw the scrollbar. See
`WebViewController.setVerticalScrollBarEnabled`,
`WebViewController.setHorizontalScrollBarEnabled`,
`WebViewController.supportsSetScrollBarsEnabled`.
* Updates README to indicate that Android SDK <21 is no longer supported.

## 4.11.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ dependencies:
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ../
webview_flutter_android: ^4.4.0
webview_flutter_wkwebview: ^3.19.0
webview_flutter_android: ^4.5.0
webview_flutter_wkwebview: ^3.21.0

dev_dependencies:
build_runner: ^2.1.5
Expand All @@ -27,7 +27,7 @@ dev_dependencies:
sdk: flutter
integration_test:
sdk: flutter
webview_flutter_platform_interface: ^2.11.0
webview_flutter_platform_interface: ^2.12.0

flutter:
uses-material-design: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,24 @@ class WebViewController {
return platform.setOnScrollPositionChange(onScrollPositionChange);
}

/// Whether the vertical scrollbar should be drawn or not.
Future<void> setVerticalScrollBarEnabled(bool enabled) {
return platform.setVerticalScrollBarEnabled(enabled);
}

/// Whether the horizontal scrollbar should be drawn or not.
Future<void> setHorizontalScrollBarEnabled(bool enabled) {
return platform.setHorizontalScrollBarEnabled(enabled);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also plumb through a Future<bool> supportsSetScrollBarsEnabled() method to the platform interface layer that clients can use to detect whether this is safe to call per https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#api-support-queries ? This won't make sense on all platforms, so we should expect that clients will need a support query indefinitely.

Copy link
Contributor Author

@bparrishMines bparrishMines Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also assuming you meant for this to return bool and not Future<bool> too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed this, and didn't catch it in the platform interface review. It should have been Future<bool> in case there were a platform that could only determine this at runtime (e.g., based on the OS version).

Not a big deal though as that's an unlikely case to ever hit.


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

/// Sets the over-scroll mode for the WebView.
///
/// Default behavior is platform dependent.
Expand Down
8 changes: 4 additions & 4 deletions packages/webview_flutter/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter
description: A Flutter plugin that provides a WebView widget backed by the system webview.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 4.11.0
version: 4.12.0

environment:
sdk: ^3.6.0
Expand All @@ -21,9 +21,9 @@ flutter:
dependencies:
flutter:
sdk: flutter
webview_flutter_android: ^4.4.0
webview_flutter_platform_interface: ^2.11.0
webview_flutter_wkwebview: ^3.19.0
webview_flutter_android: ^4.5.0
webview_flutter_platform_interface: ^2.12.0
webview_flutter_wkwebview: ^3.21.0

dev_dependencies:
build_runner: ^2.1.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,44 @@ void main() {
verify(mockPlatformWebViewController.scrollBy(2, 3));
});

test('setVerticalScrollBarEnabled', () async {
final MockPlatformWebViewController mockPlatformWebViewController =
MockPlatformWebViewController();

final WebViewController webViewController = WebViewController.fromPlatform(
mockPlatformWebViewController,
);

await webViewController.setVerticalScrollBarEnabled(true);
verify(mockPlatformWebViewController.setVerticalScrollBarEnabled(true));
});

test('setHorizontalScrollBarEnabled', () async {
final MockPlatformWebViewController mockPlatformWebViewController =
MockPlatformWebViewController();

final WebViewController webViewController = WebViewController.fromPlatform(
mockPlatformWebViewController,
);

await webViewController.setHorizontalScrollBarEnabled(false);
verify(mockPlatformWebViewController.setHorizontalScrollBarEnabled(false));
});

test('supportsSetScrollBarsEnabled', () async {
final MockPlatformWebViewController mockPlatformWebViewController =
MockPlatformWebViewController();
when(mockPlatformWebViewController.supportsSetScrollBarsEnabled())
.thenReturn(true);

final WebViewController webViewController = WebViewController.fromPlatform(
mockPlatformWebViewController,
);

expect(await webViewController.supportsSetScrollBarsEnabled(), true);
verify(mockPlatformWebViewController.supportsSetScrollBarsEnabled());
});

test('getScrollPosition', () async {
final MockPlatformWebViewController mockPlatformWebViewController =
MockPlatformWebViewController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,28 @@ class MockPlatformWebViewController extends _i1.Mock
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
_i5.Future<void> setVerticalScrollBarEnabled(bool? enabled) =>
(super.noSuchMethod(
Invocation.method(#setVerticalScrollBarEnabled, [enabled]),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
_i5.Future<void> setHorizontalScrollBarEnabled(bool? enabled) =>
(super.noSuchMethod(
Invocation.method(#setHorizontalScrollBarEnabled, [enabled]),
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);

@override
bool supportsSetScrollBarsEnabled() => (super.noSuchMethod(
Invocation.method(#supportsSetScrollBarsEnabled, []),
returnValue: false,
) as bool);

@override
_i5.Future<_i3.Offset> getScrollPosition() => (super.noSuchMethod(
Invocation.method(#getScrollPosition, []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,28 @@ class MockPlatformWebViewController extends _i1.Mock
returnValueForMissingStub: _i7.Future<void>.value(),
) as _i7.Future<void>);

@override
_i7.Future<void> setVerticalScrollBarEnabled(bool? enabled) =>
(super.noSuchMethod(
Invocation.method(#setVerticalScrollBarEnabled, [enabled]),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),
) as _i7.Future<void>);

@override
_i7.Future<void> setHorizontalScrollBarEnabled(bool? enabled) =>
(super.noSuchMethod(
Invocation.method(#setHorizontalScrollBarEnabled, [enabled]),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),
) as _i7.Future<void>);

@override
bool supportsSetScrollBarsEnabled() => (super.noSuchMethod(
Invocation.method(#supportsSetScrollBarsEnabled, []),
returnValue: false,
) as bool);

@override
_i7.Future<_i3.Offset> getScrollPosition() => (super.noSuchMethod(
Invocation.method(#getScrollPosition, []),
Expand Down