creacion de setting y limpiar city
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:city_repository/city_repository.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];
|
||||
}
|
||||
@@ -14,6 +14,5 @@ class CityUi extends Equatable {
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props =>
|
||||
[cityName, coordsOfCity, stateOfCity, countryOfCity];
|
||||
List<Object?> get props => [cityName, coordsOfCity, stateOfCity, countryOfCity];
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:city_repository/city_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 'country.dart';
|
||||
export 'region.dart';
|
||||
export 'city.dart';
|
||||
export 'city_ui.dart';
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:city_repository/city_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];
|
||||
}
|
||||
@@ -4,8 +4,7 @@ import 'package:city_repository/city_repository.dart';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
class FirebaseCityRepository implements CityRepository {
|
||||
final citiesCollection =
|
||||
FirebaseFirestore.instance.collection('countries v2');
|
||||
final citiesCollection = FirebaseFirestore.instance.collection('countries v2');
|
||||
|
||||
List<CityUi>? _cities;
|
||||
|
||||
@@ -27,10 +26,11 @@ class FirebaseCityRepository implements CityRepository {
|
||||
for (var region in country.regions) {
|
||||
for (var city in region.cities) {
|
||||
cities.add(CityUi(
|
||||
cityName: city.name,
|
||||
coordsOfCity: city.coords,
|
||||
stateOfCity: region.name,
|
||||
countryOfCity: country.name));
|
||||
cityName: city.name,
|
||||
coordsOfCity: city.coords,
|
||||
stateOfCity: region.name,
|
||||
countryOfCity: country.name,
|
||||
));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -137,30 +137,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.5"
|
||||
firebase_storage:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: firebase_storage
|
||||
sha256: ce1b0efe8dc111058c5f079b2f2ce84906d030d0fd2eef70c42ca1253c67039a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.6.9"
|
||||
firebase_storage_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_storage_platform_interface
|
||||
sha256: "4a2b64d4dac096390a0b7f2e7b6d086d0546c4a1bf7ee3fc4b5ae4cc41005c46"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.1.12"
|
||||
firebase_storage_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_storage_web
|
||||
sha256: "4153814db8d59138e816d9f016736e4095c45675a2c18f2868d11ffd8cc6a4ca"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.7.3"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -184,14 +160,6 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -15,7 +15,6 @@ dependencies:
|
||||
# Firebase
|
||||
firebase_auth: ^4.17.4
|
||||
cloud_firestore: ^4.15.4
|
||||
firebase_storage: ^11.6.5
|
||||
firebase_core: ^2.25.4
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user