DiscoverModule/lib/contacts_module/model_class/speaker.dart

56 lines
1.5 KiB
Dart
Raw Normal View History

2024-08-13 10:46:26 +00:00
// To parse this JSON data, do
//
2024-10-07 12:41:28 +00:00
// final speaker = speakerFromJson(jsonString);
2024-08-13 10:46:26 +00:00
import 'dart:convert';
2024-10-07 12:41:28 +00:00
List<Speaker> speakerFromJson(String str) =>
List<Speaker>.from(json.decode(str).map((x) => Speaker.fromJson(x)));
2024-08-13 10:46:26 +00:00
2024-10-07 12:41:28 +00:00
String speakerToJson(List<Speaker> data) =>
2024-08-13 10:46:26 +00:00
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
2024-10-07 12:41:28 +00:00
class Speaker {
2024-08-13 10:46:26 +00:00
int id;
String programtopic;
String speakername;
String role;
String evaluatorname;
String programdate;
DateTime createdAt;
DateTime updatedAt;
2024-10-07 12:41:28 +00:00
Speaker({
2024-08-13 10:46:26 +00:00
required this.id,
required this.programtopic,
required this.speakername,
required this.role,
required this.evaluatorname,
required this.programdate,
required this.createdAt,
required this.updatedAt,
});
2024-10-07 12:41:28 +00:00
factory Speaker.fromJson(Map<String, dynamic> json) => Speaker(
2024-08-13 10:46:26 +00:00
id: json["id"],
programtopic: json["programtopic"],
speakername: json["speakername"],
role: json["role"],
evaluatorname: json["evaluatorname"],
programdate: json["programdate"],
createdAt: DateTime.parse(json["created_at"]),
updatedAt: DateTime.parse(json["updated_at"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"programtopic": programtopic,
"speakername": speakername,
"role": role,
"evaluatorname": evaluatorname,
"programdate": programdate,
"created_at": createdAt.toIso8601String(),
"updated_at": updatedAt.toIso8601String(),
};
}