You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
class SourceLocationsModel {
|
|
String source_name = '';
|
|
String supplierId = '';
|
|
String status = '';
|
|
String address = '';
|
|
String deliveries = '13';
|
|
String commision = '';
|
|
String phone = '';
|
|
String dbId = '';
|
|
String water_type = '';
|
|
double longitude = 0.0;
|
|
double latitude = 0.0;
|
|
|
|
SourceLocationsModel();
|
|
|
|
factory SourceLocationsModel.fromJson(Map<String, dynamic> json) {
|
|
SourceLocationsModel rtvm = SourceLocationsModel();
|
|
|
|
rtvm.source_name = json['location_name'] ?? '';
|
|
rtvm.dbId = json['_id'] ?? '';
|
|
rtvm.supplierId = json['supplierId'] ?? '';
|
|
rtvm.status = json['status'] ?? '';
|
|
rtvm.address = json['address'] ?? '';
|
|
rtvm.phone = json['phone'] ?? '';
|
|
rtvm.water_type = json['water_type'] ?? '';
|
|
|
|
// ✅ Safely handle both int and double types
|
|
var lon = json['longitude'];
|
|
var lat = json['latitude'];
|
|
|
|
if (lon is int) {
|
|
rtvm.longitude = lon.toDouble();
|
|
} else if (lon is double) {
|
|
rtvm.longitude = lon;
|
|
} else {
|
|
rtvm.longitude = 0.0;
|
|
}
|
|
|
|
if (lat is int) {
|
|
rtvm.latitude = lat.toDouble();
|
|
} else if (lat is double) {
|
|
rtvm.latitude = lat;
|
|
} else {
|
|
rtvm.latitude = 0.0;
|
|
}
|
|
|
|
return rtvm;
|
|
}
|
|
}
|