Could you further specify what it is that you get as a result? Is the whole list full of null? Or are some of the objects' fields null?
Here is what I believe is an error:
nameUser: json['tenNguoiDung'] == null ? '' : json['ten']
avatarUser: json['nguoiDung_anhDinhKem'] == null ? '' : json['avatar'],
You are saying:
If
tenNguoiDung
is null: nameUser is equal to '', if it isn't, nameUser = json['ten'].
But your json doesn't have a 'ten' field, so it will be null. What you are most likely looking for is the if-null operator:
nameUser: json['tenNguoiDung'] ?? ''
avatarUser: json['nguoiDung_anhDinhKem'] ?? ''
which will assign ''
if the json field is null.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.