Created
March 4, 2020 06:45
-
-
Save haidar786/0dd613439ca63a979afb13b70422ab6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": 1, | |
"breed": "Rottweiler", | |
"name": "Mackie", | |
"age": 8 | |
} | |
class Dog { | |
int id; | |
String breed; | |
String name; | |
int age; | |
Dog({this.id, this.breed, this.name, this.age}); | |
Dog.fromJson(Map<String, dynamic> json) { | |
id = json['id']; | |
breed = json['breed']; | |
name = json['name']; | |
age = json['age']; | |
} | |
Map<String, dynamic> toJson() { | |
final Map<String, dynamic> data = new Map<String, dynamic>(); | |
data['id'] = this.id; | |
data['breed'] = this.breed; | |
data['name'] = this.name; | |
data['age'] = this.age; | |
return data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment