I have this response of an API
{
"error": "",
"success": {
"data": [
{
"id": "00005432",
"channel": "B22",
"case_status_id": "1",
"case_type_id": "0",
"provider_group_id": "1",
"user_id": "78",
"contact_id": null,
"client_id": "23982",
"subject": "parallala",
"description": "",
"latest_development": "",
"priority": "medium",
"caseArrivalDate": "2022-08-29",
"arrivalDate": "2022-08-29",
"dueDate": null,
"closedOn": null,
"statusComments": "dsdde 663171471 (ndnendn ))////#-#-&# # # # #(",
"category": "edefrfr",
"caseValue": "0.00",
"internalReference": null,
"externalizeLawyers": "no",
"createdOn": "2022-08-29 10:59:46",
"createdBy": "14",
"modifiedOn": "2022-09-27 18:35:43",
"requestedByName": null,
"legal_case_stage_id": null,
"caseClientPosition": null,
"clientForeignName": null
}
],
"totalRows": "1122",
"dbDriver": "MYSQL"
}
}
I think its a Map(keys,values) and inside the key(success) we have another Map
How i can get access into a specific element?
CodePudding user response:
I will assume that this value is assigned to a map type variable, I will name it response
so to access the id :
response["success"]["data"][0]["id"]
CodePudding user response:
for ex. that is my data
const String _SexData = """[
{
"sex": "Seçiniz / Choice",
"x": 1000
},
{
"sex": "Male",
"x": 1001
},
{
"sex": "Female",
"x": 1002
}
]""";
and I calling it;
DropdownButton<int>(
iconEnabledColor: Colors.blue,
dropdownColor: const Color.fromARGB(255, 28, 185, 242),
style: const TextStyle(color: Colors.black),
value: sex?.x ?? 1000,
items: model1.sexs.map((a) {
return DropdownMenuItem(
child: Text(a.sex,
style: const TextStyle(color: Colors.white)),
value: a.x,
onTap: () {
setState(() {
sex = a;
});
},
);
}).toList(),
onChanged: (s) {},
),