Skip to content

Commit

Permalink
[webview_flutter_lwe] Supports multiple JavaScriptChannel method call (
Browse files Browse the repository at this point in the history
  • Loading branch information
JSUYA authored Jun 21, 2024
1 parent c5b04a8 commit c783f99
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion packages/webview_flutter_lwe/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## NEXT
## 0.3.1

* Fix new lint warnings.
* Update minimum Flutter and Dart version to 3.13 and 3.1.
* Supports multiple JavaScriptChannel method call.

## 0.3.0

Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter_lwe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore
```yaml
dependencies:
webview_flutter: ^4.4.2
webview_flutter_lwe: ^0.3.0
webview_flutter_lwe: ^0.3.1
```
## Example
Expand Down
14 changes: 7 additions & 7 deletions packages/webview_flutter_lwe/lib/src/lwe_webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LweWebView {

final Map<String, JavaScriptChannelParams> _javaScriptChannelParams =
<String, JavaScriptChannelParams>{};
final Map<String, dynamic> _pendingMethodCalls = <String, dynamic>{};
final List<(String, dynamic)> _pendingMethodCalls = <(String, dynamic)>[];

Future<bool?> _onMethodCall(MethodCall call) async {
switch (call.method) {
Expand All @@ -48,7 +48,7 @@ class LweWebView {

Future<T?> _invokeChannelMethod<T>(String method, [dynamic arguments]) async {
if (!_isCreated) {
_pendingMethodCalls[method] = arguments;
_pendingMethodCalls.add((method, arguments));
return null;
}

Expand All @@ -66,15 +66,15 @@ class LweWebView {
}

/// Applies the requested settings before [TizenView] is created.
void _callPendingMethodCalls() {
Future<void> _callPendingMethodCalls() async {
if (hasNavigationDelegate) {
_invokeChannelMethod<void>(
await _invokeChannelMethod<void>(
'hasNavigationDelegate', hasNavigationDelegate);
}

_pendingMethodCalls.forEach((String method, dynamic arguments) {
_lweWebViewChannel.invokeMethod<void>(method, arguments);
});
for (final (String method, dynamic arguments) in _pendingMethodCalls) {
await _lweWebViewChannel.invokeMethod<void>(method, arguments);
}
_pendingMethodCalls.clear();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter_lwe/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_lwe
description: Tizen implementation of the webview_flutter plugin backed by Lightweight Web Engine.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/webview_flutter_lwe
version: 0.3.0
version: 0.3.1

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

0 comments on commit c783f99

Please sign in to comment.