Flutter Image.Network and CachedNetworkImage are not displaying?

5,842

I was Having the same issue follow the steps below :

1) If you are on your emulator close it, or on real device just uninstall the application.

2) Change the DNS Configuration on you Mac/laptop

link to change DNS for Windows :https://www.windowscentral.com/how-change-your-pcs-dns-settings-windows-10

Link to change DNs for MAC :https://www.macinstruct.com/node/434

using Google's DNS on my computer worked for me, following are the coordinates for the DNS :'8.8.8.8 and 8.8.4.4'

Let me know if it works.

Share:
5,842
Tembero
Author by

Tembero

Updated on December 18, 2022

Comments

  • Tembero
    Tembero over 1 year

    When I try to show an image to the user it cannot be seen.

    Image.network('https://picsum.photos/250?image=9')

    I've tried adding <uses-permission android:name="android.permission.INTERNET" /> to the AndroidManifest.xml file.

    Still not displaying.

    I have not tried this with IOS.

    Also I've realised I'm getting an error as follows: The following SocketException was thrown resolving an image codec: 'picsum.photos' (OS Error: No address associated with host.

    Any idea on how I could fix this?

    Edit 1:

    this is the code for that I'm using:

    CachedNetworkImage(
     imageUrl: '$server/cdn/post/img?id=${this.id}', httpHeaders: imgHeaders,
     placeholder: (BuildContext context, String url) {
      return Center(child: CircularProgressIndicator());
     },
     errorWidget: (context, url, error) => Icon(Icons.error),
    ),
    

    The server is my localhost url and it works fine as I am using it to fetch some data from my nodejs server and it works.

    this.id is my widget's argument which is equal to an id that server will use to serve the correct image. It is defined and has a value.

    Also this is a child of a Stack widget if that helps. Plus I've had this with other urls as well.