Data.fromJson constructor Null safety
Implementation
Data.fromJson(Map<String, dynamic> json) {
id = json['id'] ?? '';
type = json['type'] ?? '';
if (json['attributes'] != null) {
attributes = Attributes.fromJson(json['attributes']);
} else {
print(json['attributes'].toString());
}
relationships = <Relationship>[];
if (json['relationships'] != null) {
json['relationships'].forEach((v) {
relationships.add(Relationship.fromJson(v));
});
}
}