I am trying to build a flutter app and I am trying to show up website in a webview I am using "flutter_webview_plugin: ^0.3.11" now I am trying to evaluate some javascript in order to delete some items before displaying the web page here is the code of the webview:
@override
Widget build(BuildContext context) {
return WebviewScaffold(
url: 'https://www.amazon.com',
appBar: AppBar(
title: Text('Amazon store'),
),
initialChild: WebviewAnimation(),
withJavascript: true,
);
and here is the code of evaluating I am listening to onStateChanged like below:
void initState() {
super.initState();
_onUrlChanged = flutterWebViewPlugin.onUrlChanged.listen((event) {
this.url = event;
});
_onStateChanged =
flutterWebViewPlugin.onStateChanged.listen((WebViewStateChanged state) {
if (mounted) {
setState(() {
flutterWebViewPlugin.hide();
var kiki = flutterWebViewPlugin.evalJavascript(
"document.getElementsByClassName(\"a-button-stack\")[0].style.display='none';");
_history.add('onStateChanged: ${state.type} ${state.url}');
kiki.then((value) {
setState(() {
flutterWebViewPlugin.show();
});
});
});
}
});
by doing this I am able to evaluate js, the problem is it takes too long to evaluate, therefore I want to show up the page once it has been evaluated...any ideas ...thanks in advance