{"data":[{"id":"32f","regionName":"Korea","companyName":"Machine","catDealerCode":null},{"id":"cbb","regionName":"Korea","companyName":"KR","catDealerCode":null},{"id":"b6125b0e-5ec9",,"regionName":"China","companyName":"CHN","catDealerCode":null}],"code":0,"message":null}
I have data like the one you see above. I extract data according to the companyName. but some countries don't have data. I want to create an if else case within this.but no matter what I do when I say element == null it doesn't accept. Does anyone know where I am doing wrong? How should I create an if else for empty data?
onTap: () async {
List<Country> country =
await fetchList(
snapshot.data.code);
country.forEach((element) {
if(element.companyName == null){
print('element is empty');
}else{
print('Here ${element.companyName}');
}
});
},
Aucun commentaire:
Enregistrer un commentaire