more game details

This commit is contained in:
2025-12-04 15:54:43 +01:00
parent e04e57d2d2
commit 31b31d0e17
5 changed files with 166 additions and 14 deletions
+12
View File
@@ -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,
);
}