This commit is contained in:
Felipe
2024-03-13 13:59:33 -05:00
parent 312cc3d863
commit a25bc6a987
26 changed files with 684 additions and 60 deletions
@@ -1,46 +0,0 @@
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];
}
@@ -1,42 +0,0 @@
import 'package:equatable/equatable.dart';
import 'package:user_repository/user_repository.dart';
class Country extends Equatable {
final String name;
final List<Region> regions;
const Country({
required this.name,
required this.regions,
});
static const empty = Country(name: '', regions: []);
Country copyWith({
String? name,
List<Region>? regions,
}) {
return Country(
name: name ?? this.name,
regions: regions ?? this.regions,
);
}
bool get isEmpty => this == Country.empty;
bool get isNotEmpty => this != Country.empty;
Country toEntity() {
return Country(name: name, regions: regions);
}
static Country fromEntity(CountryEntity entity) {
return Country(
name: entity.name,
regions:
entity.regions.map((region) => Region.fromEntity(region)).toList(),
);
}
@override
List<Object?> get props => [name, regions];
}
@@ -1,4 +1 @@
export 'my_user.dart';
export 'country.dart';
export 'region.dart';
export 'city.dart';
export 'my_user.dart';
@@ -1,41 +0,0 @@
import 'package:equatable/equatable.dart';
import 'package:user_repository/user_repository.dart';
class Region extends Equatable {
final String name;
final List<City> cities;
const Region({
required this.name,
required this.cities,
});
static const empty = Region(name: '', cities: []);
Region copyWith({
String? name,
List<City>? cities,
}) {
return Region(
name: name ?? this.name,
cities: cities ?? this.cities,
);
}
bool get isEmpty => this == Region.empty;
bool get isNotEmpty => this != Region.empty;
Region toEntity() {
return Region(name: name, cities: cities);
}
static Region fromEntity(RegionEntity entity) {
return Region(
name: entity.name,
cities: entity.cities.map((city) => City.fromEntity(city)).toList(),
);
}
@override
List<Object?> get props => [name, cities];
}