webview_flutter How to evaluate Javascript at each page?

582 Views Asked by At

I am using a webview_flutter and want to evaluate Javascript at each navigation. So far, evaluateJavascript only works on the initial page. Any idea how to make it work for every page?

This is my set up:

Flutter 1.22.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 84f3d28555 (7 days ago) • 2020-10-15 16:26:19 -0700
Engine • revision b8752bbfff
Tools • Dart 2.10.2
...
webview_flutter: ^1.0.5

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

I got it to work in a roundabout way. Through trial and error, I came to conclude that either evaluateJavascript is evaluated once but always kept.

So my solution was to put the js code in an interval. Due to the nature of the application, it seems a satisfying solution. (The application is mainly used to find documents, so it is a "search, download file and close app" situation)