Skip to content

Instantly share code, notes, and snippets.

@haidar786
Created March 4, 2020 06:45
Show Gist options
  • Save haidar786/0dd613439ca63a979afb13b70422ab6f to your computer and use it in GitHub Desktop.
Save haidar786/0dd613439ca63a979afb13b70422ab6f to your computer and use it in GitHub Desktop.
{
"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