more game details
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import '../../../core/status.dart';
|
||||
|
||||
class Game {
|
||||
@@ -12,6 +13,7 @@ class Game {
|
||||
final String? coverUrl;
|
||||
final int? releaseYear;
|
||||
final bool locked;
|
||||
final Map<String, dynamic>? rawJson;
|
||||
|
||||
Game({
|
||||
required this.id,
|
||||
@@ -25,9 +27,18 @@ class Game {
|
||||
this.coverUrl,
|
||||
this.releaseYear,
|
||||
this.locked = false,
|
||||
this.rawJson,
|
||||
});
|
||||
|
||||
factory Game.fromJson(Map<String, dynamic> j) {
|
||||
Map<String, dynamic>? parsedJson;
|
||||
final jsonString = j['json'] as String?;
|
||||
if (jsonString != null && jsonString.isNotEmpty) {
|
||||
try {
|
||||
parsedJson = Map<String, dynamic>.from(
|
||||
jsonDecode(jsonString) as Map<dynamic, dynamic>);
|
||||
} catch (_) {}
|
||||
}
|
||||
return Game(
|
||||
id: (j['id'] as num).toInt(),
|
||||
igdbId: (j['igdb_id'] as num).toInt(),
|
||||
@@ -40,6 +51,7 @@ class Game {
|
||||
coverUrl: j['cover_url'] as String?,
|
||||
releaseYear: (j['release_year'] as num?)?.toInt(),
|
||||
locked: ((j['loc_locked'] ?? j['locked'] ?? 0) as num?)?.toInt() == 1,
|
||||
rawJson: parsedJson,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user