Files
fcs/lib/domain/vo/delivery_address.dart

54 lines
1.4 KiB
Dart
Raw Normal View History

2020-10-08 11:38:05 +06:30
class DeliveryAddress {
String id;
String fullName;
String addressLine1;
String addressLine2;
String city;
String state;
String phoneNumber;
2020-10-11 02:17:23 +06:30
bool isDefault;
2020-10-08 11:38:05 +06:30
DeliveryAddress(
2020-10-08 15:54:43 +06:30
{this.id,
this.fullName,
2020-10-08 11:38:05 +06:30
this.addressLine1,
this.addressLine2,
this.city,
this.state,
2020-10-11 02:17:23 +06:30
this.phoneNumber,
this.isDefault = false});
2020-10-08 11:38:05 +06:30
2020-10-08 15:54:43 +06:30
factory DeliveryAddress.fromMap(Map<String, dynamic> map, String docID) {
return DeliveryAddress(
id: docID,
fullName: map['full_name'],
addressLine1: map['address_line1'],
addressLine2: map['address_line2'],
city: map['city'],
state: map['state'],
phoneNumber: map['phone_number'],
2020-10-11 02:17:23 +06:30
isDefault: map['is_defalut'] ?? false,
2020-10-08 15:54:43 +06:30
);
}
2020-10-08 11:38:05 +06:30
Map<String, dynamic> toMap() {
return {
"id": id,
'full_name': fullName,
'address_line1': addressLine1,
'address_line2': addressLine2,
'city': city,
'state': state,
'phone_number': phoneNumber,
};
}
bool isChangedForEdit(DeliveryAddress deliveryAddress) {
return deliveryAddress.fullName != this.fullName ||
deliveryAddress.phoneNumber != this.phoneNumber ||
deliveryAddress.addressLine1 != this.addressLine1 ||
deliveryAddress.addressLine2 != this.addressLine2 ||
deliveryAddress.state != this.state ||
deliveryAddress.city != this.city;
}
2020-10-08 11:38:05 +06:30
}