class model
unknown
dart
2 years ago
2.0 kB
3
Indexable
class WorkerModel { String image; String name; String location; int experience; double hourRate; double rating; double ratingCount; String status; String about; List<String> strengths; String category; String $id; String $createdAt; String $updateAt; WorkerModel({ required this.image, required this.name, required this.location, required this.experience, required this.hourRate, required this.rating, required this.ratingCount, required this.status, required this.about, required this.strengths, required this.category, required this.$id, required this.$createdAt, required this.$updateAt, }); factory WorkerModel.fromJson(Map<String, dynamic> json) => WorkerModel( image: json["image"] ?? "", name: json["name"] ?? "", location: json["location"] ?? "", experience: json["experience"], hourRate: json["hour_rate"]?.toDouble() ?? 0.0, rating: json["rating"]?.toDouble() ?? 0.0, ratingCount: json["rating_count"]?.toDouble() ?? 0.0, status: json["status"] ?? "", about: json["about"] ?? "", strengths: json["strengths"] == null ? [] : List<String>.from(json["strengths"].map((x) => x)), category: json["category"] ?? "", $id: json["\$id"], $createdAt: json["\$createdAt"], $updateAt: json["\$updateAt"], ); Map<String, dynamic> toJson() => { "image": image, "name": name, "location": location, "experience": experience, "hour_rate": hourRate, "rating": rating, "rating_count": ratingCount, "status": status, "about": about, "strengths": List<dynamic>.from(strengths.map((x) => x)), "category": category, "\$id": $id, "\$createdAt": $createdAt, "\$updateAt": $updateAt, }; }
Editor is loading...
Leave a Comment