addJavascriptChannels method
Adds new JavaScript channels to the set of enabled channels.
For each value in this list the platform's webview should make sure that a corresponding
property with a postMessage method is set on window
. For example for a JavaScript channel
named Foo
it should be possible for JavaScript code executing in the webview to do
Foo.postMessage('hello');
See also: CreationParams.javascriptChannelNames
.
Implementation
@override
Future<void> addJavascriptChannels(Set<String> javascriptChannelNames) {
return Future.wait(
javascriptChannelNames.where(
(String channelName) {
return !_javaScriptChannels.containsKey(channelName);
},
).map<Future<void>>(
(String channelName) {
final WebViewAndroidJavaScriptChannel javaScriptChannel =
WebViewAndroidJavaScriptChannel(
channelName, javascriptChannelRegistry);
_javaScriptChannels[channelName] = javaScriptChannel;
return webView.addJavaScriptChannel(javaScriptChannel);
},
),
);
}