I am confusing some Map to List conversion in dart.
For example;
Map<String ,dynamic> datas= "RJGas": {
"unit_deatils": {
"total_obs": 3,
"previous_obs": 3,
"difference": 0,
"indicator": "green",
"critical_period": [
"17:00",
"17:59"
],
"critical_obs": "HK"
},
"zone_deatils": {
"RGT Well Pads 04": {
"total_obs": 0,
"previous_obs": 2,
"difference": -2,
"indicator": "green",
"critical_period": [],
"critical_obs": ""
},
"RGT Well pads 01": {
"total_obs": 2,
"previous_obs": 0,
"difference": 2,
"indicator": "red",
"critical_period": [
"17:00",
"17:59"
],
"critical_obs": "HK"
},
"RGT Well": {
"total_obs": 1,
"previous_obs": 1,
"difference": 0,
"indicator": "green",
"critical_period": [],
"critical_obs": ""
},
"RGT Well 01": {
"total_obs": 0,
"previous_obs": 0,
"difference": 0,
"indicator": "green",
"critical_period": [],
"critical_obs": ""
}
}
},
I want to get a list include only zone details data, how to get all zone details in to a List,
I want to the output be like,
List zoneDatas = [
"RGT Well Pads 04": {
"total_obs": 0,
"previous_obs": 2,
"difference": -2,
"indicator": "green",
"critical_period": [],
"critical_obs": ""
},
"RGT Well pads 01": {
"total_obs": 2,
"previous_obs": 0,
"difference": 2,
"indicator": "red",
"critical_period": [
"17:00",
"17:59"
],
"critical_obs": "HK"
},
"RGT Well": {
"total_obs": 1,
"previous_obs": 1,
"difference": 0,
"indicator": "green",
"critical_period": [],
"critical_obs": ""
},
"RGT Well 01": {
"total_obs": 0,
"previous_obs": 0,
"difference": 0,
"indicator": "green",
"critical_period": [],
"critical_obs": ""
}
]
I am stucking this map to List conversion, Please add your valuable replays,hopefully
2
Answers
Your
datas
declaration is not correct, I think you should add some{
like this:Then you can access
zone_deatils
like this:The output format that you provided is not correct, since it is a map. If you still want a list, then you can try this:
You can try