This commit is contained in:
Phuoc Nguyen
2025-11-25 18:00:01 +07:00
parent 84669ac89c
commit 5e9b0cb562
9 changed files with 337 additions and 167 deletions

View File

@@ -62,6 +62,10 @@ class AddressModel extends HiveObject {
@HiveField(11)
String? wardName;
/// Whether editing this address is allowed
@HiveField(12)
bool isAllowEdit;
AddressModel({
required this.name,
required this.addressTitle,
@@ -75,6 +79,7 @@ class AddressModel extends HiveObject {
this.isDefault = false,
this.cityName,
this.wardName,
this.isAllowEdit = true,
});
/// Create from JSON (API response)
@@ -92,6 +97,7 @@ class AddressModel extends HiveObject {
isDefault: json['is_default'] == 1 || json['is_default'] == true,
cityName: json['city_name'] as String?,
wardName: json['ward_name'] as String?,
isAllowEdit: json['is_allow_edit'] == 1 || json['is_allow_edit'] == true,
);
}
@@ -111,6 +117,7 @@ class AddressModel extends HiveObject {
'is_default': isDefault,
if (cityName != null && cityName!.isNotEmpty) 'city_name': cityName,
if (wardName != null && wardName!.isNotEmpty) 'ward_name': wardName,
'is_allow_edit': isAllowEdit,
};
}
@@ -129,6 +136,7 @@ class AddressModel extends HiveObject {
isDefault: isDefault,
cityName: cityName,
wardName: wardName,
isAllowEdit: isAllowEdit,
);
}
@@ -147,12 +155,14 @@ class AddressModel extends HiveObject {
isDefault: entity.isDefault,
cityName: entity.cityName,
wardName: entity.wardName,
isAllowEdit: entity.isAllowEdit,
);
}
@override
String toString() {
return 'AddressModel(name: $name, addressTitle: $addressTitle, '
'addressLine1: $addressLine1, phone: $phone, isDefault: $isDefault)';
'addressLine1: $addressLine1, phone: $phone, isDefault: $isDefault, '
'isAllowEdit: $isAllowEdit)';
}
}