import 'FileModel.dart'; import 'RideOptionModel.dart'; import 'TaxiOptionsModel.dart'; import 'Vehicle.dart'; class Driver { int? id; List? driverLicence; FileModel? driverpatent; List? nationalidmedia; FileModel? taxilicence; RideOptionModel? rideoption; List? taxioption; int? licenseExpiryDate; int? referralcount; String? nationalid; String? taxid; String? status; String? patentnumber; String? driverName; Vehicle? vehicle; bool available; double? rating; double? dailyearnings; double? currentLatitude; double? currentLongitude; bool? verified; int? registrationDate; int? totalRidesCompleted; int? totalRidesCanceled; int? totalRidesIgnored; String? city; String? referralCode; int? timestamp; int? totalRatingUer; Driver({ this.id, this.driverLicence, this.licenseExpiryDate, this.driverpatent, this.nationalidmedia, this.taxilicence, this.nationalid, this.taxid, this.referralcount, this.dailyearnings, this.driverName, this.vehicle, this.taxioption, required this.available, this.rideoption, this.rating, this.currentLatitude, this.status, this.currentLongitude, this.verified, this.registrationDate, this.totalRidesCompleted, this.totalRidesCanceled, this.totalRidesIgnored, this.city, this.referralCode, this.timestamp, this.patentnumber, this.totalRatingUer, }); factory Driver.fromJson(Map json) { return Driver( id: json['id'], driverName: json['driverName'], driverLicence: (json['driverlicence'] as List?) ?.map((item) => FileModel.fromJson(item as Map)) .toList() ?? [], // driverLicence: json['driverlicence'] != null ? FileModel.fromJson(json['driverlicence']) : null, nationalidmedia: (json['nationalidmedia'] as List?) ?.map((item) => FileModel.fromJson(item as Map)) .toList() ?? [], // nationalidmedia: json['nationalidmedia'] != null ? FileModel.fromJson(json['nationalidmedia']) : null, driverpatent: json['driverpatent'] != null ? FileModel.fromJson(json['driverpatent']) : null, taxilicence: json['taxilicence'] != null ? FileModel.fromJson(json['taxilicence']) : null, licenseExpiryDate: json['licenseexpirydate'], nationalid: json['nationalid'], taxid: json['taxid'], referralcount: json['referralcount'] ?? 0, vehicle: json['vehicle'] != null ? Vehicle.fromJson(json['vehicle']) : null, rideoption: json['rideoption'] != null ? RideOptionModel.fromJson(json['rideoption']) : null, taxioption: json['taxioption'] != null ? (json['taxioption'] as List) .map((item) => TaxiOptionModel.fromJson(item as Map)) .toList() : null, available: json['available'] ?? false, patentnumber: json['patentnumber'], referralCode: json['referralCode'], rating: json['rating']?.toDouble(), dailyearnings: json['dailyearnings'] ?? 0.0, currentLatitude: json['currentlatitude']?.toDouble(), currentLongitude: json['currentlongitude']?.toDouble(), verified: json['verified'], registrationDate: json['registrationDate'], totalRidesCompleted: json['totalridecompleted'] ?? 0, totalRidesCanceled: json['totalridecanceled'] ?? 0, totalRidesIgnored: json['totalrideignored'], city: json['city'], status: json['status'], totalRatingUer: json['totalratinguser']??0, timestamp: json['timestmp'], ); } Map toJson() { return { 'id': id, 'driverName': driverName, 'driverlicence': driverLicence?.map((img) => img.toJson()).toList(), // 'driverlicence': driverLicence?.toJson(), 'driverpatent': driverpatent?.toJson(), 'nationalidmedia': nationalidmedia?.map((img) => img.toJson()).toList(), // 'nationalidmedia': nationalidmedia?.toJson(), 'taxilicence': taxilicence?.toJson(), 'licenseexpirydate': licenseExpiryDate, 'nationalid': nationalid, 'taxid': taxid, 'vehicle': vehicle?.toJson(), 'rideoption': rideoption?.toJson(), 'taxioption': taxioption?.map((t) => t.toJson()).toList(), 'available': available, 'patentnumber': patentnumber, 'rating': rating, 'currentlatitude': currentLatitude, 'currentlongitude': currentLongitude, 'verified': verified, 'registrationDate': registrationDate, 'totalridecompleted': totalRidesCompleted, 'totalridecanceled': totalRidesCanceled, 'totalrideignored': totalRidesIgnored, 'city': city, 'status': status, 'referralcount': referralcount, 'referralCode': referralCode, 'timestmp': timestamp, }; } @override String toString() { return 'Driver{id: $id, driverLicence: $driverLicence, driverpatent: $driverpatent, nationalidmedia: $nationalidmedia, taxilicence: $taxilicence, rideoption: $rideoption, taxioption: $taxioption, licenseExpiryDate: $licenseExpiryDate, nationalid: $nationalid, taxid: $taxid, status: $status, patentnumber: $patentnumber, driverName: $driverName, vehicle: $vehicle, available: $available, rating: $rating, dailyearnings: $dailyearnings, currentLatitude: $currentLatitude, currentLongitude: $currentLongitude, verified: $verified, registrationDate: $registrationDate, totalRidesCompleted: $totalRidesCompleted, totalRidesCanceled: $totalRidesCanceled, totalRidesIgnored: $totalRidesIgnored, city: $city, timestamp: $timestamp, totalRatingUer: $totalRatingUer}'; } }