webview_flutter plugin - some website cannot load some website

Viewed 1397

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()
      ],
    );
  }
1 Answers

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.

Related