UserRecentlyPlayedGameEntity.fromJson constructor
UserRecentlyPlayedGameEntity.fromJson(
- Map<String, dynamic> json
)
Implementation
factory UserRecentlyPlayedGameEntity.fromJson(Map<String, dynamic> json) {
final rawGameId = json['gameId'] ?? json['GameID'] ?? 0;
final rawConsoleId = json['consoleId'] ?? json['ConsoleID'] ?? 0;
final rawVote = json['myVote'] ?? json['MyVote'];
final rawNumPossible =
json['numPossibleAchievements'] ?? json['NumPossibleAchievements'] ?? 0;
final rawPossibleScore =
json['possibleScore'] ?? json['PossibleScore'] ?? 0;
final rawNumAchieved = json['numAchieved'] ?? json['NumAchieved'] ?? 0;
final rawScoreAchieved =
json['scoreAchieved'] ?? json['ScoreAchieved'] ?? 0;
final rawNumAchievedHc =
json['numAchievedHardcore'] ?? json['NumAchievedHardcore'] ?? 0;
final rawScoreAchievedHc =
json['scoreAchievedHardcore'] ?? json['ScoreAchievedHardcore'] ?? 0;
return UserRecentlyPlayedGameEntity(
gameId: rawGameId is num
? rawGameId.toInt()
: int.parse(rawGameId.toString()),
consoleId: rawConsoleId is num
? rawConsoleId.toInt()
: int.parse(rawConsoleId.toString()),
consoleName: (json['consoleName'] ?? json['ConsoleName'] ?? '') as String,
title: (json['title'] ?? json['Title'] ?? '') as String,
imageIcon: (json['imageIcon'] ?? json['ImageIcon'] ?? '') as String,
lastPlayed: (json['lastPlayed'] ?? json['LastPlayed'] ?? '') as String,
myVote: rawVote != null
? (rawVote is num ? rawVote.toInt() : int.parse(rawVote.toString()))
: null,
numPossibleAchievements: rawNumPossible is num
? rawNumPossible.toInt()
: int.parse(rawNumPossible.toString()),
possibleScore: rawPossibleScore is num
? rawPossibleScore.toInt()
: int.parse(rawPossibleScore.toString()),
numAchieved: rawNumAchieved is num
? rawNumAchieved.toInt()
: int.parse(rawNumAchieved.toString()),
scoreAchieved: rawScoreAchieved is num
? rawScoreAchieved.toInt()
: int.parse(rawScoreAchieved.toString()),
numAchievedHardcore: rawNumAchievedHc is num
? rawNumAchievedHc.toInt()
: int.parse(rawNumAchievedHc.toString()),
scoreAchievedHardcore: rawScoreAchievedHc is num
? rawScoreAchievedHc.toInt()
: int.parse(rawScoreAchievedHc.toString()),
);
}