Am using webview_flutter in my flutter app which views a web page comes from the backend of my project. some times I need to use JS to send a message from the web page to my flutter app .. and am using this method for this :
the web page
theCenter.postMessage(myElement.innerHTML); //Sending whatever content as a string
Flutter App
JavascriptChannel(
name: 'theCenter',
onMessageReceived:
(JavascriptMessage message) {
controller.getNewCenter(message.message);
}),
The error now comes from the webpage itself as it shows me this error in the console:
Uncaught (in promise) ReferenceError: theCenter is not defined