Data.fromJson constructor Null safety

Data.fromJson(
  1. Map<String, dynamic> json
)

Implementation

Data.fromJson(Map<String, dynamic> json) {
  id = json['id'] ?? '';
  type = json['type'] ?? '';
  attributes = Attributes.fromJson(json['attributes']);
  relationships = [];
  if (json['relationships'] != null) {
    json['relationships'].forEach((e) {
      relationships.add(RelationShip.fromJson(e));
    });
  }
}