47 lines
807 B
Dart
47 lines
807 B
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
import '../entities/entities.dart';
|
|
|
|
class City extends Equatable {
|
|
final String name;
|
|
final String coords;
|
|
|
|
const City({
|
|
required this.name,
|
|
required this.coords,
|
|
});
|
|
|
|
static const empty = City(name: '', coords: '');
|
|
|
|
City copyWith({
|
|
String? name,
|
|
String? coords,
|
|
}) {
|
|
return City(
|
|
name: name ?? this.name,
|
|
coords: coords ?? this.coords,
|
|
);
|
|
}
|
|
|
|
bool get isEmpty => this == City.empty;
|
|
|
|
bool get isNotEmpty => this != City.empty;
|
|
|
|
City toEntity() {
|
|
return City(
|
|
name: name,
|
|
coords: coords,
|
|
);
|
|
}
|
|
|
|
static City fromEntity(CityEntity entity) {
|
|
return City(
|
|
name: entity.name,
|
|
coords: entity.coords,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [name, coords];
|
|
}
|