class AttendanceModel { final String id; final String name; final String projectAddress; final String contactPerson; final DateTime startDate; final DateTime endDate; final int teamSize; final double completedWork; final double plannedWork; AttendanceModel({ required this.id, required this.name, required this.projectAddress, required this.contactPerson, required this.startDate, required this.endDate, required this.teamSize, required this.completedWork, required this.plannedWork, }); factory AttendanceModel.fromJson(Map json) { return AttendanceModel( id: json['id']?.toString() ?? '', name: json['name'] ?? '', projectAddress: json['projectAddress'] ?? '', contactPerson: json['contactPerson'] ?? '', startDate: DateTime.tryParse(json['startDate']?.toString() ?? '') ?? DateTime.now(), endDate: DateTime.tryParse(json['endDate']?.toString() ?? '') ?? DateTime.now(), teamSize: int.tryParse(json['teamSize']?.toString() ?? '') ?? 0, completedWork: double.tryParse(json['completedWork']?.toString() ?? '') ?? 0, plannedWork: double.tryParse(json['plannedWork']?.toString() ?? '') ?? 0, ); } Map toJson() { return { 'id': id, 'name': name, 'projectAddress': projectAddress, 'contactPerson': contactPerson, 'startDate': startDate.toIso8601String(), 'endDate': endDate.toIso8601String(), 'teamSize': teamSize, 'completedWork': completedWork, 'plannedWork': plannedWork, }; } }