Created
June 2, 2020 09:19
-
-
Save Saravana2/4b63f168827d02180297864277e83041 to your computer and use it in GitHub Desktop.
In Flutter, touch and click events are not working in webview. so instead of write click event in dart.. write click event on Javascript by element tag name, class name or id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebView( | |
initialUrl: "https://github.com/login", | |
onWebViewCreated: (controller) { | |
_myController = controller; | |
}, | |
onPageFinished: (url) { | |
_myController.evaluateJavascript( | |
"document.getElementsByName('commit')[0].addEventListener('click',function(){ try { showResult.postMessage(document.getElementById('login_field').value); } catch (err) {} });"); | |
}, | |
onPageStarted: (url) {}, | |
javascriptMode: JavascriptMode.unrestricted, | |
javascriptChannels: Set.from([ | |
JavascriptChannel( | |
name: "showResult", | |
onMessageReceived: (JavascriptMessage result) { | |
if (result.message != null && result.message != "") { | |
// The result data will be stored in result.message | |
}}),]),) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment