英文:
How to display some object data inside array object Flutter
问题
I hope you have a great day, I'm still learning Flutter, and I have some difficulties displaying some data.
So I have this List data
listData = [{someData: Lorem #1, image: linkToSomeImage}]
and I need to display the image using Image.network(image).
But I don't know why. I tried listData[0].image or listData[0]["image"] to populate the variable, but it doesn't work, and I get all the red ![]()
What is the correct way to do this?
英文:
i hope you have a great day, i'm still learn Flutter, and i have some difficulties to display some data
so i have this List data
listData = [{someData: Lorem #1, image: linkToSomeImage}]
and i need to display the image to Image.network(image),
but i don't know why, i tried listData[0].image or listData[0]["image"] to populate the variable but it can't works, and got all the red ![]()
what is the correct way to do this?
答案1
得分: 1
数据将通过运算符[]和key来访问,因为你有JSON(Map)列表。
listData[0]["image"]
使用方式如下:
Row(
  children: [
    for(int i=0; i< listData.length; i++)
      Image.network(listData[i]['image']),
  ]
)
英文:
As you have the list of json(Map), data will be accessed by operator [] with key
listData[0]["image"]
and usage will be
Row(
  children: [
    for(int i=0; i< listData.length; i++)
      Image.network(listData[i]['image`]),
  ]
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论