javascriptChannels property

Set<JavascriptChannel> javascriptChannels

The set of JavascriptChannels available to JavaScript code running in the web view.

For each JavascriptChannel in the set, a channel object is made available for the JavaScript code in a window property named The JavaScript code can then call postMessage on that object to send a message that will be passed to JavascriptChannel.onMessageReceived.

For example for the following JavascriptChannel:

JavascriptChannel(name: 'Print', onMessageReceived: (JavascriptMessage message) { print(message.message); });

JavaScript code can call:


To asynchronously invoke the message handler which will print the message to standard output.

Adding a new JavaScript channel only takes affect after the next page is loaded.

Set values must not be null. A cannot be the same for multiple channels in the list.

A null value is equivalent to an empty set.


final Set<JavascriptChannel> javascriptChannels;