Skip to content

[webview_flutter_platform_interface] Adds method to set overscroll mode #9099

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

Merged
Merged
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,5 +1,6 @@
## NEXT
## 2.11.0

* Adds support to set the over-scroll mode for the WebView. See `PlatformWebViewController.setOverScrollMode`.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.

## 2.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ abstract class PlatformWebViewController extends PlatformInterface {
'setOnJavaScriptTextInputDialog is not implemented on the current platform',
);
}

/// Sets the over-scroll mode for the WebView.
Future<void> setOverScrollMode(WebViewOverScrollMode mode) async {
throw UnimplementedError(
'setOverScrollMode 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,16 @@
// 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 over-scroll behavior of a WebView.
enum WebViewOverScrollMode {
/// Always allow a user to over-scroll the WebView.
always,

/// Allow a user to over-scroll the WebView only if the content is larger than
/// the viewport.
ifContentScrolls,

/// Never allow a user to over-scroll the WebView.
never,
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export 'javascript_mode.dart';
export 'load_request_params.dart';
export 'navigation_decision.dart';
export 'navigation_request.dart';
export 'over_scroll_mode.dart';
export 'platform_navigation_delegate_creation_params.dart';
export 'platform_webview_controller_creation_params.dart';
export 'platform_webview_cookie_manager_creation_params.dart';
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.10.0
version: 2.11.0

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

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

expect(
() => controller.setOverScrollMode(WebViewOverScrollMode.always),
throwsUnimplementedError,
);
});
}

class MockWebViewPlatformWithMixin extends MockWebViewPlatform
Expand Down