I have this dynamic list which I am decoding from a json response, it goes as
[{Calcium: [47.92, mg, Red, 0.00169033008, ounce]}, {Choline: [71.88, mg, Red, 0.00253549512, ounce]}, {Copper: [0.08, mg, Red, 0.00000282192, ounce]}, {Crude fat: [70.28, g, Green, 2.47905672, ounce]}, {Folate: [23.96, mcg, Red, 0.00000084516504, ounce]}...]
In that I need to check whether a given key exists. for an example check key "Calcium" exists and if so I need to fetch the value of index 0 and index 2 of the array belongs to that key, I want to perform this in an iterative way.
how can I achieve this in dart?
I have tried this but it does not work , maybe I'm doing it in a wrong way.
nutrientList.forEach((element) {
if(nutrientList.contains("Calcium")) {
valCalcium = element.calcium[0];
calciumClr = element.calcium[2];
} else {}