Reputation: 63
My Flutter app loads a webpage using the webview_flutter package. I have successfully passed info from the webpage to Flutter, using javascriptChannels. I have also successfully run built-in Javascript, from Flutter to the webpage. (Like launching an alert!)
But! How can I execute a Javascript function on the webpagem from Flutter. (Not merely run a built-in Javascript methods?)
Say my webpage has a function called helloWord(), what is the dart code to trigger that function from Flutter?
Upvotes: 0
Views: 429
Reputation: 63
DOH! I needed to add the "window" object to the front of the function...
So this code did the trick:
_webViewController.runJavascript('window.helloWorld()');
I am posting in case others have this issue.
Upvotes: 0