prosapp_web_app has chat, dashboard, calendar, support, 13 providers and Fluro URL routing. Keep Dockerfile + nginx.conf from previous prosappweb. Upgrade google_fonts 6.2.1 → 8.1.0 (Dart 3.12 compat fix). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
import 'package:prosapp_web_app/models/city.dart';
|
|
import 'package:prosapp_web_app/models/country_entity.dart';
|
|
|
|
class CitiesProvider extends ChangeNotifier {
|
|
List<City> cities = [];
|
|
bool isLoading = true;
|
|
|
|
final _citiesCollection =
|
|
FirebaseFirestore.instance.collection('countries v2');
|
|
|
|
CitiesProvider() {
|
|
getCities();
|
|
}
|
|
|
|
getCoordsOfCity(String cityName) {
|
|
if (cities.isEmpty) return null;
|
|
|
|
for (var city in cities) {
|
|
if (city.cityName == cityName) {
|
|
return city.coordsOfCity;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
getCities() async {
|
|
try {
|
|
final querySnapshot = await _citiesCollection.doc('Colombia').get();
|
|
|
|
final data = querySnapshot.data();
|
|
|
|
final country = CountryEntity.fromDocument(data as Map<String, dynamic>);
|
|
|
|
for (var region in country.regions) {
|
|
for (var city in region.cities) {
|
|
cities.add(City(
|
|
cityName: city.name,
|
|
coordsOfCity: city.coords,
|
|
stateOfCity: region.name,
|
|
countryOfCity: country.name,
|
|
));
|
|
}
|
|
}
|
|
|
|
cities.sort((a, b) => a.cityName.compareTo(b.cityName));
|
|
} catch (e) {
|
|
print('Error obteniendo ciudades: $e');
|
|
} finally {
|
|
isLoading = false;
|
|
notifyListeners();
|
|
}
|
|
}
|
|
}
|