webview_flutter plugin - some website cannot load some website

851

Well I facing this issue about 4 months back, and at that time I used the plugin which you are using. The problem was that I have not allowed javascript and local storage for the web view. I would recommend you to use flutter_webview_plugin and allow javascript and local storage for the webview. It would work.

Share:
851
khoi
Author by

khoi

Updated on January 01, 2023

Comments

  • khoi
    khoi over 1 year

    I developed an app using flutter. Right now I want to open a website from WebView and It worked but some websites are not loading inside webview. I'm not sure what I've done wrong, Hope someone can help me to solve this problem. Thank you in advance.

    plugin: https://pub.dev/packages/webview_flutter/example

    URL work: https://flutter.dev/

    URL that is not working: https://belanjawan2021.treasury.gov.my/manfaat/index.php/bm/pemulih-bkc

    Error

    Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

    enter image description here

      Widget webView() {
        return Stack(
          children: [
            WebView(
                onPageStarted: (String url) {
                  setState(() {
                    _showProgress = true;
                  });
                },
                onPageFinished: (String url) {
                  setState(() {
                    _showProgress = false;
                  });
                },
                initialUrl: widget.feed.url,
                onWebResourceError: (WebResourceError webviewerrr) {
                  print("webview_flutter:" + webviewerrr.description);
                },
                javascriptMode: JavascriptMode.unrestricted,
                onProgress: (int progress) {}),
            _showProgress
                ? Center(
                    child: SizedBox(
                    child: CircularProgressIndicator(),
                    height: 200,
                    width: 200,
                  ))
                : Stack()
          ],
        );
      }
    
    • Ali Yar Khan
      Ali Yar Khan over 2 years
      It is not necessary that you are making mistakes ? As u said that some websites are working fine and others aren't, this means they have some restrictions or are not well-designed for mobile. Additionally, you can share errors while visiting to those sites to have a clear view
    • khoi
      khoi over 2 years
      @AliYarKhan I added an error message, I think it's related to the current problem.