Fixed toJson methods

This commit is contained in:
2025-11-18 23:46:32 +01:00
parent 2da2e28cb6
commit fd86f5193f
3 changed files with 13 additions and 9 deletions

View File

@@ -35,7 +35,11 @@ class Game {
winner = json['winner'] ?? '';
/// Converts the Game instance to a JSON object.
String toJson() {
return 'Game{id: $id,name: $name,players: $players,group: $group,winner: $winner}';
}
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'players': players?.map((player) => player.toJson()).toList(),
'group': group?.toJson(),
'winner': winner,
};
}