serializeData static method
Sérialise les listes d’étudiants et d’écoles dans une structure JSON.
Affiche des statistiques sur les étudiants acceptés ou refusés dans la console.
students
: Liste des objets Student
.
schools
: Liste des objets School
.
Retourne une Map<String, dynamic>
représentant les données prêtes à être sauvegardées.
Implementation
static Map<String, dynamic> serializeData(List<Student> students, List<School> schools){
print("Stats about the file \n Currently ${students.where((e) => e.accepted != null).length} students have an accepted choice \n and ${students.where((e) => e.refused.isNotEmpty).length} students have a refused choice");
print("We currently have ${students.length} students and ${schools.length} schools ");
Map<String, List<dynamic>> finalData = {"students" : [], "schools" : []};
for (var student in students){
finalData["students"]?.add(student.toJson());
}
for (var school in schools){
finalData["schools"]?.add(school.toJson());
}
return finalData;
}