PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 29, 2022

[FIXED] How to display image which comes from API response in flutter

 July 29, 2022     api, flutter, image     No comments   

Issue

I'm trying to display the image which i get from api response.

here my api response look like

{
            "id": 40,
            "user_id": 49,
            "contact_person": "fss",
            "relation": "dfs",
            "phone": "dsf",
            "image": "emergency/1735859198927595.jpg",
            "created_at": "2022-06-17T05:38:54.000000Z",
            "updated_at": "2022-06-17T05:38:54.000000Z"
        },

and displaying it on listtile leading like this

ListTile(leading: SizedBox(height: 50,width: 50,
         child: Image.network(emergencyContact[index].image))

but it gives me this error

Exception caught by image resource service ════════════════════════════
Invalid argument(s): No host specified in URI file:///emergency/1735859198927595.jpg

please help how to fix this issue.


Solution

So the Exception Error explains very well that you did not provide your host: https://your.site.com/image-path.png

Please append https://your.site.com/${emergencyContact[index].image}

ListTile(leading: SizedBox(height: 50,width: 50,
         child: Image.network(`https://your.site.com/${emergencyContact[index].image}`))


Answered By - Davis
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing