class EventModel { List? events; EventModel({this.events}); EventModel.fromJson(Map json) { if (json['events'] != null) { events = []; json['events'].forEach((v) { events!.add(Events.fromJson(v)); }); } } Map toJson() { final Map data = {}; if (events != null) { data['events'] = events!.map((v) => v.toJson()).toList(); } return data; } } class Events { int? id; String? title; String? description; String? subtitle; String? awards; String? image; String? startAt; String? endAt; bool? isOpen; int? totalParticipants; int? totalReceivedWorks; List? winners; Events( {this.id, this.title, this.description, this.subtitle, this.awards, this.image, this.startAt, this.endAt, this.isOpen, this.totalParticipants, this.totalReceivedWorks, this.winners}); Events.fromJson(Map json) { id = json['id']; title = json['title']; description = json['description']; subtitle = json['subtitle']; awards = json['awards']; image = json['image']; startAt = json['start_at']; endAt = json['end_at']; isOpen = json['is_open']; totalParticipants = json['total_participants']; totalReceivedWorks = json['total_received_works']; if (json['winners'] != null) { winners = []; json['winners'].forEach((v) { winners!.add(Winners.fromJson(v)); }); } } Map toJson() { final Map data = {}; data['id'] = id; data['title'] = title; data['description'] = description; data['subtitle'] = subtitle; data['awards'] = awards; data['image'] = image; data['start_at'] = startAt; data['end_at'] = endAt; data['is_open'] = isOpen; data['total_participants'] = totalParticipants; data['total_received_works'] = totalReceivedWorks; if (winners != null) { data['winners'] = winners!.map((v) => v.toJson()).toList(); } return data; } } class Winners { int? rank; String? username; Winners({this.rank, this.username}); Winners.fromJson(Map json) { rank = json['rank']; username = json['username']; } Map toJson() { final Map data = {}; data['rank'] = rank; data['username'] = username; return data; } }