title: EvaluateJavascript does not work in Webview flutter. Why isn't the JS fulfilled?
body: <p>I am using <code>evaluateJavascript</code> with js code
  <code>document.getElementsByTagName ('main') [0] .style.display = 'none'</code> but it fails <code>_webController.evaluateJavascript (&quot;document.getElementsByTagName ('main') [0] .style.display = 'none'&quot;, );</code></p>
  <p>I have already tried everything in order to perform my own JS on the webview page, JS is not performed in any way.
  What could be the problem ?? Why is it not working?</p>
  <p>Code:</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:webview_flutter/platform_interface.dart';
  import 'package:webview_flutter/webview_flutter.dart';
  import 'package:url_launcher/url_launcher.dart';
  import 'package:animated_splash_screen/animated_splash_screen.dart';
  import 'package:location/location.dart';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
          home: AnimatedSplashScreen(
            splash: Image.asset(
              'assets/animation.gif',
            ),
            nextScreen: YellowBird(),
            // nextScreen: MainScreen(),
            splashTransition: SplashTransition.slideTransition,
          ),
        );
      }
  }
  
  class MainScreen extends StatelessWidget {
    late WebViewController _webController;
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          body: Column(
            children: [
              Expanded(
                child: WebView(
                  
                  javascriptMode: JavascriptMode.unrestricted,
                  initialUrl: 'http://212.80.206.193/test.project-270.com/',
                  debuggingEnabled: true,
                  onWebViewCreated: (controller) {
                    _webController = controller;
                    _webController.clearCache();
                  },
                 
                  onPageStarted: (url) {
                    _webController.evaluateJavascript(&quot;document.getElementsByTagName('main')[0].style.display ='none'&quot;,);
                  },
                  navigationDelegate: (NavigationRequest request) {
                    print(request.url);
                    if (request.url.contains(&quot;geo:&quot;)) {
                      launch(request.url);
                      return NavigationDecision.prevent;
                    } else {
                    return NavigationDecision.navigate;
                    }
                  },
                ),
              ),
            ],
          ),
        ),
      );
    }
  }
  
  class YellowBird extends StatefulWidget {
    @override
    MainLocation createState() =&gt; MainLocation();
  }
  
  class MainLocation extends State&lt;StatefulWidget&gt; {
    Location location = new Location();
    late bool _isSeviceEnabled;
    late PermissionStatus _permissionGranted;
    late LocationData _locationData;
    bool _isListenLocation = false, _isGetLocation = false;
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: SafeArea(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(onPressed: () async{
                _isSeviceEnabled = await location.serviceEnabled();
                if(!_isSeviceEnabled){
                  _isSeviceEnabled = await location.requestService();
                  if (_isSeviceEnabled) return;
                }
  
                _permissionGranted = await location.hasPermission();
                if(_permissionGranted == PermissionStatus.denied){
                  _permissionGranted = await location.requestPermission();
                  if (_permissionGranted != PermissionStatus.granted) return;
                }
                _locationData = await location.getLocation();
                setState(() {
                    _isGetLocation = true;
                });
              }, child: Text('Get Location')),
              _isGetLocation ? Text('Location: ${_locationData.latitude} ${_locationData.longitude}') : Container(),
              ElevatedButton(onPressed: () async{Navigator.of(context).push(MaterialPageRoute(builder: (context) =&gt; MainScreen()));}, child: Text('Proceed')),
            ],
          ),
        ),
      );  
    }
  }
  </code></pre>
  <p>Please help me solve this problem!!</p>