Added fromJson, toJson

This commit is contained in:
2025-11-18 23:16:57 +01:00
parent 07d623d963
commit d86de09042
3 changed files with 40 additions and 0 deletions

View File

@@ -10,4 +10,14 @@ class Player {
String toString() {
return 'Player{id: $id,name: $name}';
}
/// Creates a Player instance from a JSON object.
Player.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'];
/// Converts the Player instance to a JSON object.
String toJson() {
return 'Player{id: $id,name: $name}';
}
}