Skip to content

Instantly share code, notes, and snippets.

@AbhishekDoshi26
Created August 5, 2021 17:19
Show Gist options
  • Save AbhishekDoshi26/9370f349db668f713cd68f0180e2ab91 to your computer and use it in GitHub Desktop.
Save AbhishekDoshi26/9370f349db668f713cd68f0180e2ab91 to your computer and use it in GitHub Desktop.
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