Added fromJson, toJson
This commit is contained in:
@@ -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}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user