Search code examples
mongodbimageflutterflutter-layoutdio

How can I display image from get request on screen in flutter?


I am new to flutter. I am facing issues in displaying image on the screen that I am getting from MongoDB. The image I am getting is in the format "somenameofimage.jpg" or "somenameofimage.png". I have searched for it, but every I see NetworkImage used for loading images from internet I guess or from assets. I am getting the result of get request in a variable that has other details like name contact etc as well.


Solution

  • i use this to get image from server

                   Container(
                          decoration: BoxDecoration(
                                  shape: BoxShape.circle,
                                  image: DecorationImage(
                                      image: profileData.imageAddress != null
                                          ? NetworkImage(
                                                  profileData.imageAddress)
    

    NetworkImage works fine for me... look at the URL for the picture put it in your browser to see if it is correct or not

    this works too

    Image.network(profileData.imageAddress,)