I am trying to fetch the JSON data coming by the Http library. I would like to diplay only the "alert_description" value for the first object to user. How i can access to this attribut ?
My API respone :
{
"code": 0,
"message": " success",
"data": {
"data": {
"current_page": 1,
"data": [
{
"id": 62,
"user_id": 53,
"boxIdentifiant": 1924589682265245,
"boxName": "Box Sfax",
"alert_date": "2021-05-30",
"alert_time": "09:40",
"alert_description": "Panne Pression",
"alert_level": "warning"
},
{
"id": 61,
"user_id": 53,
"boxIdentifiant": 1924589682265243,
"boxName": "Box Tunis",
"alert_date": "2021-05-30",
"alert_time": "09:40",
"alert_description": "Panne Pression Roux",
"alert_level": "info"
},
{
"id": 58,
"user_id": 53,
"boxIdentifiant": 1924589682265244,
"boxName": "Box Office",
"alert_date": "2021-05-30",
"alert_time": "09:40",
"alert_description": "Panne Pression Roux",
"alert_level": "warning"
},
My code :
var response =
await http.get(Uri.parse(ApiUtil.GET_ALERT), headers: headers);
print("here================");
// print(response);
var data = json.decode(response.body);
print(data['data']['data']['data']);
if (data['status'] == 200) {
showNotification(data['message'], flp);
} else {
print("no message");
}
return Future.value(true);
});
}