Game.fromJson constructor
get the model from the json
Implementation
factory Game.fromJson(Map<String, dynamic> json) {
return Game(
id: json["id"] ?? 0,
slug: json["slug"] ?? "",
name: json["name"] ?? "",
rating: json["rating"] ?? 0,
metacriticRating: json["metacritic"] ?? 0,
nameOriginal: json["name_original"] ?? "",
description: json["description"] ?? "",
released: json["released"] ?? "",
tba: json["tba"] ?? false,
backgroundImage: json["background_image"] ?? "",
website: json["website"] ?? "",
playtime: json["playtime"] ?? 0,
achievementsCount: json["achievements_count"] ?? 0,
alternativeNames: json["alternative_names"] == null
? []
: List<String>.from(
json["alternative_names"]!.map(
(x) => x,
),
),
platforms: json["platforms"] == null
? []
: List<Platform>.from(
json["platforms"]!.map(
(x) => Platform.fromJson(
x["platform"],
),
),
),
);
}