Q: Flutter : How to convert a element of JSON to list? I have a problem, how to make list contains "logo" element from JSON and the result will be like this?
List<String> logo = [
'assets/images/event/482dd2272b83506e0e3c70cb86b65ec1.jpg',
'assets/images/event/3caf5cf0f593dae4a686b765c8db02f3.jpg',
'assets/images/event/3caf5cf0f593dae4a686b765c8db02f3.jpg',
];

and the JSON code below:
[
    {
        "id": "278",
        "nama": "KFC Super Deal",
        "tglawal": "07 Sep 2020",
        "tglakhir": "13 Sep 2020",
        "jenis": "Promo",
        "tenant": "KFC",
        "logo": "assets/images/event/482dd2272b83506e0e3c70cb86b65ec1.jpg"
    },
    {
        "id": "277",
        "nama": "Cash Back 150K",
        "tglawal": "20 Aug 2020",
        "tglakhir": "30 Aug 2020",
        "jenis": "Promo",
        "tenant": "SPORT STATION",
        "logo": "assets/images/event/3caf5cf0f593dae4a686b765c8db02f3.jpg"
    },
    {
        "id": "276",
        "nama": "Cash Back 150K",
        "tglawal": "20 Aug 2020",
        "tglakhir": "30 Aug 2020",
        "jenis": "Promo",
        "tenant": "SKECHERS",
        "logo": "assets/images/event/5138cbf11662ad982828209376b71ddd.jpg"
    },
]

Anyone know how to solve my problem? Thank you :)

A: You can do like this
List<String> logo = new List<String>();
  
  var response = [
    {
        "id": "278",
        "nama": "KFC Super Deal",
        "tglawal": "07 Sep 2020",
        "tglakhir": "13 Sep 2020",
        "jenis": "Promo",
        "tenant": "KFC",
        "logo": "assets/images/event/482dd2272b83506e0e3c70cb86b65ec1.jpg"
    },
    {
        "id": "277",
        "nama": "Cash Back 150K",
        "tglawal": "20 Aug 2020",
        "tglakhir": "30 Aug 2020",
        "jenis": "Promo",
        "tenant": "SPORT STATION",
        "logo": "assets/images/event/3caf5cf0f593dae4a686b765c8db02f3.jpg"
    },
    {
        "id": "276",
        "nama": "Cash Back 150K",
        "tglawal": "20 Aug 2020",
        "tglakhir": "30 Aug 2020",
        "jenis": "Promo",
        "tenant": "SKECHERS",
        "logo": "assets/images/event/5138cbf11662ad982828209376b71ddd.jpg"
    },
];
  
  for(int i=0; i < response.length; i++){
    logo.add(response[i]['logo']);
  }
  print(logo);

then the output will be like this
['assets/images/event/482dd2272b83506e0e3c70cb86b65ec1.jpg',
'assets/images/event/3caf5cf0f593dae4a686b765c8db02f3.jpg',
'assets/images/event/3caf5cf0f593dae4a686b765c8db02f3.jpg',]


A: The simplest way is to use for loop and spread operator:
  final logos = [
    for (var element in json) ...{
      element['logo'],
    }
  ];

  print(logos);

