Skip to content

Commit

Permalink
[webview_flutter_tizen] Supports multiple JavaScriptChannel method call
Browse files Browse the repository at this point in the history
This is the same issue as webview_flutter_lwe.
refer to flutter-tizen#693
This supports the case of calling multiple JavaScriptChannel methods.
  • Loading branch information
JSUYA committed Jun 18, 2024
1 parent 4721c7d commit fe366e6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/webview_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.2

* Supports multiple JavaScriptChannel method call.

## 0.9.1

* Add ewk_set_version_policy() call.
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore
```yaml
dependencies:
webview_flutter: ^4.4.2
webview_flutter_tizen: ^0.9.1
webview_flutter_tizen: ^0.9.2
```
## Example
Expand Down
20 changes: 18 additions & 2 deletions packages/webview_flutter/lib/src/tizen_webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ class TizenWebView {

Future<T?> _invokeChannelMethod<T>(String method, [dynamic arguments]) async {
if (!_isCreated) {
_pendingMethodCalls[method] = arguments;
if (method == 'addJavaScriptChannel' ||
method == 'runJavaScript' ||
method == 'runJavaScriptReturningResult') {
_pendingMethodCalls['${method}_$arguments'] = arguments;
} else {
_pendingMethodCalls[method] = arguments;
}
return null;
}

Expand All @@ -79,7 +85,17 @@ class TizenWebView {
}

_pendingMethodCalls.forEach((String method, dynamic arguments) {
_tizenWebViewChannel.invokeMethod<void>(method, arguments);
if (method.contains('addJavaScriptChannel_')) {
_tizenWebViewChannel.invokeMethod<void>(
'addJavaScriptChannel', arguments);
} else if (method.contains('runJavaScript_')) {
_tizenWebViewChannel.invokeMethod<void>('runJavaScript', arguments);
} else if (method.contains('runJavaScriptReturningResult_')) {
_tizenWebViewChannel.invokeMethod<void>(
'runJavaScriptReturningResult', arguments);
} else {
_tizenWebViewChannel.invokeMethod<void>(method, arguments);
}
});
_pendingMethodCalls.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_tizen
description: Tizen implementation of the webview_flutter plugin.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/webview_flutter
version: 0.9.1
version: 0.9.2

environment:
sdk: ">=3.1.0 <4.0.0"
Expand Down

0 comments on commit fe366e6

Please sign in to comment.