first commit
This commit is contained in:
89
app/lib/domain/entities/location.dart
Normal file
89
app/lib/domain/entities/location.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class Location extends Equatable {
|
||||
final int id;
|
||||
final int locationId;
|
||||
final int version;
|
||||
final String name;
|
||||
final String? street;
|
||||
final String? number;
|
||||
final String? zip;
|
||||
final String? city;
|
||||
final double? latitude;
|
||||
final double? longitude;
|
||||
final String? remark;
|
||||
|
||||
const Location({
|
||||
required this.id,
|
||||
required this.locationId,
|
||||
required this.version,
|
||||
required this.name,
|
||||
this.street,
|
||||
this.number,
|
||||
this.zip,
|
||||
this.city,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.remark,
|
||||
});
|
||||
|
||||
Location copyWith({
|
||||
int? id,
|
||||
int? locationId,
|
||||
int? version,
|
||||
String? name,
|
||||
String? street,
|
||||
String? number,
|
||||
String? zip,
|
||||
String? city,
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
String? remark,
|
||||
}) {
|
||||
return Location(
|
||||
id: id ?? this.id,
|
||||
locationId: locationId ?? this.locationId,
|
||||
version: version ?? this.version,
|
||||
name: name ?? this.name,
|
||||
street: street ?? this.street,
|
||||
number: number ?? this.number,
|
||||
zip: zip ?? this.zip,
|
||||
city: city ?? this.city,
|
||||
latitude: latitude ?? this.latitude,
|
||||
longitude: longitude ?? this.longitude,
|
||||
remark: remark ?? this.remark,
|
||||
);
|
||||
}
|
||||
|
||||
String get fullAddress {
|
||||
final parts = <String>[];
|
||||
if (street != null && street!.isNotEmpty) {
|
||||
parts.add(street!);
|
||||
if (number != null && number!.isNotEmpty) {
|
||||
parts.add(number!);
|
||||
}
|
||||
}
|
||||
if (zip != null && zip!.isNotEmpty) {
|
||||
parts.add(zip!);
|
||||
}
|
||||
if (city != null && city!.isNotEmpty) {
|
||||
parts.add(city!);
|
||||
}
|
||||
return parts.join(', ');
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
locationId,
|
||||
version,
|
||||
name,
|
||||
street,
|
||||
number,
|
||||
zip,
|
||||
city,
|
||||
latitude,
|
||||
longitude,
|
||||
remark,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user