Loading url in flutter using webview_flutter does not load images

45 Views Asked by At

I am developing a flutter app and I want to load static urls e.g. "About Us" page from the website. I am able to load the page but I have noticed that images are not fetching. I also suspect, the webview is not loading css and js assets. See the image below:

enter image description here

I have created the controller as shown below:

@override
  void initState() {
    super.initState();
    controller = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..setBackgroundColor(const Color(0x00000000))
      ..setNavigationDelegate(
        NavigationDelegate(
          onPageStarted: (url) {
            setState(() {
              loadingPercentage = 0;
            });
          },
          onProgress: (progress) {
            setState(() {
              loadingPercentage = progress;
            });
          },
          onPageFinished: (url) {
            setState(() {
              loadingPercentage = 100;
            });
          },
          onWebResourceError: (WebResourceError error) {},
        ),
      )
      ..loadRequest(Uri.parse(widget.url));
  }

on the page body, I have the following Stack:

Stack(
        children: [
          WebViewWidget(controller: controller),
          if (loadingPercentage < 100)
            LinearProgressIndicator(
              color: accentColor,
              backgroundColor: primaryLight,
              value: loadingPercentage / 100.0,
            ),
        ],
      )
0

There are 0 best solutions below