Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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,3 +1,7 @@
## 1.5.0

* Added `onUrlChanged` callback to platform callback handler.

## 1.4.0

* Added `loadFile` and `loadHtml` interface methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class MethodChannelWebViewPlatform implements WebViewPlatformController {
case 'onPageStarted':
_platformCallbacksHandler.onPageStarted(call.arguments['url']!);
return null;
case 'onUrlChanged':
_platformCallbacksHandler.onUrlChanged(call.arguments['url']!);
return null;
case 'onWebResourceError':
_platformCallbacksHandler.onWebResourceError(
WebResourceError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ abstract class WebViewPlatformCallbacksHandler {
void onPageFinished(String url);

/// Invoked by [WebViewPlatformController] when a page is loading.
/// /// Only works when [WebSettings.hasProgressTracking] is set to `true`.
/// Only works when [WebSettings.hasProgressTracking] is set to `true`.
void onProgress(int progress);

/// Invoked by [WebViewPlatformController] when the webview's URL has changed.
///
/// Unlike [onPageStarted], [onProgress], and [onPageFinished],
/// [onUrlChanged] also fires when navigating without a full page load
/// e.g. when navigating within a single page application.
void onUrlChanged(String url);

/// Report web resource loading error to the host application.
void onWebResourceError(WebResourceError error);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/master/packages/webview_flut
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: 1.4.0
version: 1.5.0

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import 'package:webview_flutter_platform_interface/webview_flutter_platform_inte
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

group('Tests on `plugin.flutter.io/webview_<channel_id>` channel', () {
group(
'Tests on `plugin.flutter.io/webview_<channel_id>` channel dart->native',
() {
const int channelId = 1;
const MethodChannel channel =
MethodChannel('plugins.flutter.io/webview_$channelId');
Expand Down Expand Up @@ -554,6 +556,40 @@ void main() {
});
});

group(
'Tests on `plugin.flutter.io/webview_<channel_id>` channel native->dart',
() {
const int channelId = 1;
final WebViewPlatformCallbacksHandler callbacksHandler =
MockWebViewPlatformCallbacksHandler();
final JavascriptChannelRegistry javascriptChannelRegistry =
MockJavascriptChannelRegistry();

MethodChannelWebViewPlatform(
channelId,
callbacksHandler,
javascriptChannelRegistry,
);

tearDown(() {
reset(callbacksHandler);
});

test('onUrlChanged', () async {
// Run
await ServicesBinding.instance!.defaultBinaryMessenger
.handlePlatformMessage(
'plugins.flutter.io/webview_$channelId',
StandardMethodCodec()
.encodeMethodCall(MethodCall('onUrlChanged', {'url': 'Test Url'})),
null,
);

// Verify
verify(callbacksHandler.onUrlChanged('Test Url'));
});
});

group('Tests on `plugins.flutter.io/cookie_manager` channel', () {
const MethodChannel cookieChannel =
MethodChannel('plugins.flutter.io/cookie_manager');
Expand Down