简体   繁体   中英

how to select a specific item from a list Flutter/Dart

i have a dynamic list which is like this below... i want to create another list which will have only "start" dates inside, how can i do this???

"bookings": [
            {
                "reference": "G1TVTZYSXZRHIIINN888",
                "station": "G61703000566",
                "connector": 0,
                "start": "2021-07-22T17:00:00.000+00:00",
                "stop": "2021-07-22T18:00:00.000+00:00",
                "card": "D2E3422B",
                "status": "Expired"
            },
            {
                "reference": "VD2MQO39CQ1PSHMUDIHT",
                "station": "G61703000567",
                "connector": 1,
                "start": "2021-07-22T18:00:00.000+00:00",
                "stop": "2021-07-22T19:00:00.000+00:00",
                "card": "D2E3422B",
                "status": "Expired"
            },
            {
                "reference": "EPQ05Q8DAHCOVNXMQCM3",
                "station": "G61703000567",
                "connector": 1,
                "start": "2021-07-22T20:00:00.000+00:00",
                "stop": "2021-07-22T21:00:00.000+00:00",
                "card": "D2E3422B",
                "status": "Expired"
            }...

Map over your json and return the start value

var data = jsonData["bookings"].map((e) => e["start"]).toList();

Try List.map and map the start key then call toList() method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM