UserCompletionProgressEntity.fromJson constructor
UserCompletionProgressEntity.fromJson(
- Map<String, dynamic> json
)
Implementation
factory UserCompletionProgressEntity.fromJson(Map<String, dynamic> json) {
final rawGameId = json['gameId'] ?? json['GameID'] ?? 0;
final rawConsoleId = json['consoleId'] ?? json['ConsoleID'] ?? 0;
final rawMaxPossible = json['maxPossible'] ?? json['MaxPossible'] ?? 0;
final rawNumAwarded = json['numAwarded'] ?? json['NumAwarded'] ?? 0;
final rawNumAwardedHc =
json['numAwardedHardcore'] ?? json['NumAwardedHardcore'] ?? 0;
return UserCompletionProgressEntity(
gameId: rawGameId is num
? rawGameId.toInt()
: int.parse(rawGameId.toString()),
title: (json['title'] ?? json['Title'] ?? '') as String,
imageIcon: (json['imageIcon'] ?? json['ImageIcon'] ?? '') as String,
consoleId: rawConsoleId is num
? rawConsoleId.toInt()
: int.parse(rawConsoleId.toString()),
consoleName: (json['consoleName'] ?? json['ConsoleName'] ?? '') as String,
maxPossible: rawMaxPossible is num
? rawMaxPossible.toInt()
: int.parse(rawMaxPossible.toString()),
numAwarded: rawNumAwarded is num
? rawNumAwarded.toInt()
: int.parse(rawNumAwarded.toString()),
numAwardedHardcore: rawNumAwardedHc is num
? rawNumAwardedHc.toInt()
: int.parse(rawNumAwardedHc.toString()),
mostRecentAwardedDate: (json['mostRecentAwardedDate'] ??
json['MostRecentAwardedDate']) as String?,
highestAwardKind: AwardKind.fromString(
(json['highestAwardKind'] ?? json['HighestAwardKind']) as String?,
),
highestAwardDate:
(json['highestAwardDate'] ?? json['HighestAwardDate']) as String?,
);
}