Created
August 5, 2021 17:19
-
-
Save AbhishekDoshi26/9370f349db668f713cd68f0180e2ab91 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
import 'dart:convert'; | |
Welcome welcomeFromJson(String str) => Welcome.fromJson(json.decode(str)); | |
String welcomeToJson(Welcome data) => json.encode(data.toJson()); | |
class Welcome { | |
Welcome({ | |
this.name, | |
this.age, | |
this.technology, | |
}); | |
String name; | |
int age; | |
List<Technology> technology; | |
factory Welcome.fromJson(Map<String, dynamic> json) => Welcome( | |
name: json["name"], | |
age: json["age"], | |
technology: List<Technology>.from(json["technology"].map((x) => Technology.fromJson(x))), | |
); | |
Map<String, dynamic> toJson() => { | |
"name": name, | |
"age": age, | |
"technology": List<dynamic>.from(technology.map((x) => x.toJson())), | |
}; | |
} | |
class Technology { | |
Technology({ | |
this.name, | |
this.experience, | |
}); | |
String name; | |
int experience; | |
factory Technology.fromJson(Map<String, dynamic> json) => Technology( | |
name: json["name"], | |
experience: json["experience"], | |
); | |
Map<String, dynamic> toJson() => { | |
"name": name, | |
"experience": experience, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment