我们如何在flutter中获得特定的json对象列表



我有一个json数据,像这样的格式

{
"ID": 2,
"Name": "krish",
"info": [{
"Time": "07:30:00",
"Image": "https://www.ingredion.com/content/dam/ingredion/usca-images/food/meat/cheeseburger-bread_720x560.jpg",
"Notes": "Test"
}, {
"Time": "08:30:00",
"Image": "https://www.refrigeratedfrozenfood.com/ext/resources/NEW_RD_Website/DefaultImages/default-pasta.jpg",
"Notes": "Test1"
}, {
"Time": "09:30:00",
"Image": "https://images.unsplash.com/photo-1520342868574-5fa3804e551c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6ff92caffcdd63681a35134a6770ed3b&auto=format&fit=crop&w=1951&q=80",
"Notes": "Testw"
}
],
"status": 5,
"data": "passed"
}

我们如何得到所有的"图像"仅使用颤振数据。提前谢谢。

你可以做

final responseMap = jsonDecode(responseString);
final infoList = responseMap['info'];
final imageList = infoList.map((info) => info['Image']).toList();

imageList将包含所有的图像链接作为字符串列表。

最新更新