this is sampele of my json response
always show error like this
2
Instead of adding null keep them as empty string ex-
{ 'class':'' }
You need to use null safety in your model class.
class Profile{ String? photo; Profile({ this.photo, }); Map<String, dynamic> toMap() { return { 'photo': photo, }; } factory Profile.fromMap(Map<String, dynamic> map) { return Profile( photo: map["profile"]['photo'] ?? "", ); } }
Click here to cancel reply.
2
Answers
Instead of adding null keep them as empty string
ex-
You need to use null safety in your model class.