I'm using webview_flutter to view a page from the URL on my Flutter application, what I need to do is to detect when changes happen in the HTML code without changing the URL. as there is some data changing overtime using JS and I need to check for HTML and fetch some data out of it whenever it changes, without the need to use any of
void Function(String)? onPageStarted,
void Function(String)? onPageFinished,
void Function(int)? onProgress,
because the page is not reloading or the URL is not changing, everything is the same but the HTML code. here is what the Web view looks like:
WebView(
gestureRecognizers: <
Factory<OneSequenceGestureRecognizer>>{
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer()),
Factory<HorizontalDragGestureRecognizer>(
() => HorizontalDragGestureRecognizer()),
Factory<ScaleGestureRecognizer>(
() => ScaleGestureRecognizer()),
},
zoomEnabled: true,
debuggingEnabled: true,
initialUrl: controller.mapURL.value,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated:
(WebViewController webViewController) {
controller.mapWebViewController =
webViewController;
},
),
and here is how to get the HTML content
var html = await controller.mapWebViewController!
.evaluateJavascript(
"window.document.getElementsByTagName('html')[0].outerHTML;");
print(HTML);