Hi I have a webView and I'm simply trying to get the value from the WebView to return true or false when the user presses a button, I have managed to console.log it, but how do I get this value and put it into flutter? Thanks.
web.WebView(
initialUrl: "https://www.tiktok.com/@tiktok",
javascriptMode: web.JavascriptMode.unrestricted,
onWebViewCreated: (web.WebViewController webViewController) {
_controller.complete(webViewController);
_myController = webViewController;
},
onPageFinished: (String url) {
_myController.evaluateJavascript("""
window.onclick = e => {
console.log(e.target.className);
console.log(e.target.tagName);
}
var element = document.getElementsByClassName('jsx-4074580611');
element[0].addEventListener('click', function(event) {
setTimeout(function (){
if(element[0].innerText == 'Following') {
console.log("True");
//RETURN TRUE TO FLUTTER
}else{
console.log("False");
//RETURN FALSE TO FLUTTER
}
}, 1500);
});
""");
},
javascriptChannels: Set.from([
])
),
);
}
}