If you are using a Flutter WebView to display web content and need to capture the response from this content, you can use JavaScript for this purpose. This allows developers to communicate between their Flutter app and the web content that is being displayed in the WebView. With this method, developers can get responses and utilize them for various purposes such as user authentication or form submissions.
To get the response of a WebView in Flutter, you can use the WebViewController
’s future
evaluateJavascript
method. Here is an example of how you can use it:
This will print the inner text of the body element of the web page in the WebView to the console when the floating action button is pressed.
Keep in mind that evaluateJavascript
returns a Future
that resolves to a String
, so you need to use await
when calling it.
LESSONS
COURSES
TUTORS
Quick Links
Legal Stuff
Social Media