Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webview_flutter_lwe] Supports multiple JavaScriptChannel method call #693

Merged
merged 3 commits into from
Jun 21, 2024
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
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
Loading