// To parse this JSON data, do // // final events = eventsFromJson(jsonString); import 'dart:convert'; List eventsFromJson(String str) => List.from(json.decode(str).map((x) => Events.fromJson(x))); String eventsToJson(List data) => json.encode(List.from(data.map((x) => x.toJson()))); class Events { int id; int userId; String eventName; String sessionType; String topic; String role; DateTime? createdAt; DateTime? updatedAt; Events({ required this.id, required this.userId, required this.eventName, required this.sessionType, required this.topic, required this.role, required this.createdAt, required this.updatedAt, }); factory Events.fromJson(Map json) => Events( id: json["id"], userId: json["user_id"], eventName: json["event_name"], sessionType: json["session_type"], topic: json["topic"], role: json["role"], createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]), updatedAt: json["updated_at"] == null ? null : DateTime.parse(json["updated_at"]), ); Map toJson() => { "id": id, "user_id": userId, "event_name": eventName, "session_type": sessionType, "topic": topic, "role": role, "created_at": createdAt?.toIso8601String(), "updated_at": updatedAt?.toIso8601String(), }; }