Skip to content

Commit 1df5c3d

Browse files
committed
[webview_flutter_lwe] Implement onUrlChange for the navigation delegate
The lightweight web engine has no dedicated URL-change callback, so report a URL change from the page-started handler: the native side now also invokes onUrlChange with the navigation URL, and LweNavigationDelegate.setOnUrlChange stores the callback and forwards the onUrlChange channel event instead of throwing UnimplementedError. Bump version to 0.4.2.
1 parent f99beac commit 1df5c3d

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

packages/webview_flutter_lwe/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.2
2+
3+
* Implement `onUrlChange` for the navigation delegate.
4+
15
## 0.4.1
26

37
* Remove Ecore API.

packages/webview_flutter_lwe/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore
2121
```yaml
2222
dependencies:
2323
webview_flutter: ^4.13.1
24-
webview_flutter_lwe: ^0.4.1
24+
webview_flutter_lwe: ^0.4.2
2525
```
2626
2727
## Example

packages/webview_flutter_lwe/lib/src/lwe_webview_controller.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ class LweNavigationDelegate extends PlatformNavigationDelegate {
388388
ProgressCallback? _onProgress;
389389
WebResourceErrorCallback? _onWebResourceError;
390390
NavigationRequestCallback? _onNavigationRequest;
391+
UrlChangeCallback? _onUrlChange;
391392

392393
/// Called when [TizenView] is created.
393394
void onCreate(int viewId) {
@@ -431,6 +432,11 @@ class LweNavigationDelegate extends PlatformNavigationDelegate {
431432
);
432433
}
433434
return null;
435+
case 'onUrlChange':
436+
if (_onUrlChange != null) {
437+
_onUrlChange!(UrlChange(url: arguments['url']! as String));
438+
}
439+
return null;
434440
}
435441

436442
throw MissingPluginException(
@@ -506,10 +512,7 @@ class LweNavigationDelegate extends PlatformNavigationDelegate {
506512

507513
@override
508514
Future<void> setOnUrlChange(UrlChangeCallback onUrlChange) async {
509-
throw UnimplementedError(
510-
'This version of `LweNavigationDelegate` currently has no '
511-
'implementation for `setOnUrlChange`',
512-
);
515+
_onUrlChange = onUrlChange;
513516
}
514517

515518
@override

packages/webview_flutter_lwe/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: webview_flutter_lwe
22
description: Tizen implementation of the webview_flutter plugin backed by Lightweight Web Engine.
33
homepage: https://github.com/flutter-tizen/plugins
44
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/webview_flutter_lwe
5-
version: 0.4.1
5+
version: 0.4.2
66

77
environment:
88
sdk: ^3.8.0

packages/webview_flutter_lwe/tizen/src/webview.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int view_id,
156156
dispatcher_->dispatchTaskOnMainThread([this, args]() {
157157
navigation_delegate_channel_->InvokeMethod(
158158
"onPageStarted", std::make_unique<flutter::EncodableValue>(args));
159+
// The lightweight web engine has no dedicated URL-change callback, so
160+
// report a URL change whenever a navigation starts.
161+
navigation_delegate_channel_->InvokeMethod(
162+
"onUrlChange", std::make_unique<flutter::EncodableValue>(args));
159163
});
160164
});
161165
webview_instance_->RegisterOnPageLoadedHandler(

0 commit comments

Comments
 (0)