From c783f995c8a21ee45a138d29bed0e53982437d68 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 21 Jun 2024 13:53:47 +0900 Subject: [PATCH] [webview_flutter_lwe] Supports multiple JavaScriptChannel method call (#693) --- packages/webview_flutter_lwe/CHANGELOG.md | 3 ++- packages/webview_flutter_lwe/README.md | 2 +- .../webview_flutter_lwe/lib/src/lwe_webview.dart | 14 +++++++------- packages/webview_flutter_lwe/pubspec.yaml | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/webview_flutter_lwe/CHANGELOG.md b/packages/webview_flutter_lwe/CHANGELOG.md index cd3a118f0..14b6648ee 100644 --- a/packages/webview_flutter_lwe/CHANGELOG.md +++ b/packages/webview_flutter_lwe/CHANGELOG.md @@ -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 diff --git a/packages/webview_flutter_lwe/README.md b/packages/webview_flutter_lwe/README.md index bea45df01..68d58b894 100644 --- a/packages/webview_flutter_lwe/README.md +++ b/packages/webview_flutter_lwe/README.md @@ -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 diff --git a/packages/webview_flutter_lwe/lib/src/lwe_webview.dart b/packages/webview_flutter_lwe/lib/src/lwe_webview.dart index 7241fa8b5..fe3747a00 100644 --- a/packages/webview_flutter_lwe/lib/src/lwe_webview.dart +++ b/packages/webview_flutter_lwe/lib/src/lwe_webview.dart @@ -24,7 +24,7 @@ class LweWebView { final Map _javaScriptChannelParams = {}; - final Map _pendingMethodCalls = {}; + final List<(String, dynamic)> _pendingMethodCalls = <(String, dynamic)>[]; Future _onMethodCall(MethodCall call) async { switch (call.method) { @@ -48,7 +48,7 @@ class LweWebView { Future _invokeChannelMethod(String method, [dynamic arguments]) async { if (!_isCreated) { - _pendingMethodCalls[method] = arguments; + _pendingMethodCalls.add((method, arguments)); return null; } @@ -66,15 +66,15 @@ class LweWebView { } /// Applies the requested settings before [TizenView] is created. - void _callPendingMethodCalls() { + Future _callPendingMethodCalls() async { if (hasNavigationDelegate) { - _invokeChannelMethod( + await _invokeChannelMethod( 'hasNavigationDelegate', hasNavigationDelegate); } - _pendingMethodCalls.forEach((String method, dynamic arguments) { - _lweWebViewChannel.invokeMethod(method, arguments); - }); + for (final (String method, dynamic arguments) in _pendingMethodCalls) { + await _lweWebViewChannel.invokeMethod(method, arguments); + } _pendingMethodCalls.clear(); } diff --git a/packages/webview_flutter_lwe/pubspec.yaml b/packages/webview_flutter_lwe/pubspec.yaml index 61e7470cb..96464d249 100644 --- a/packages/webview_flutter_lwe/pubspec.yaml +++ b/packages/webview_flutter_lwe/pubspec.yaml @@ -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"