The location system has been migrated from REST API to Firestore to provide better performance and consistency with the existing breed system.
- Document ID: Slugified name (e.g.,
turkiye) - Fields:
id: Integer IDname: Display name (e.g., "Türkiye")code: Country code (e.g., "TR")createdAt: ISO 8601 timestampupdatedAt: ISO 8601 timestamp
- Document ID: Slugified city name (e.g.,
istanbul,ankara,izmir) - Fields:
id: Integer IDname: City name (e.g., "İstanbul")countryId: Reference to country (always 1 for Turkey)plateCode: License plate code (e.g., "34")plateNumber: Plate number as integerareaCode: Phone area codepopulation: Population as stringregion: Geographic regionarea: Area in km²description: Brief descriptioncreatedAt: ISO 8601 timestampupdatedAt: ISO 8601 timestamp
- Document ID: Combined format
{city_slug}_{district_slug}or{city_slug}_merkez - Fields:
id: Integer IDname: District name (e.g., "Beşiktaş", "Ankara Merkez")cityId: Reference to parent cityplateNumber: City plate number for easier queriescreatedAt: ISO 8601 timestampupdatedAt: ISO 8601 timestamp
The slug generation handles Turkish characters properly:
- ş → s, ğ → g, ç → c, ı → i, ö → o, ü → u
- Runs on app startup via
main.dart - Checks if data exists before importing (prevents duplicates)
- Uses batch operations for efficient writes
- Removed composite indexes requirement by sorting in memory
- Uses collection-level queries without complex filtering
- Cached providers with
keepAlive: true
importLocationsFromAssets(): Import if not existsforceImportLocations(): Clear and re-import all dataclearAllLocations(): Remove all location data
getCountries(): Get all countriesgetCities(countryId): Get cities for a countrygetDistricts(cityId): Get districts for a citygetLocations(countryId, cityId): Get districts (legacy compatibility)
@Riverpod(keepAlive: true)
Future<GetLocationsResponse> fetchCountries(Ref ref)
@Riverpod(keepAlive: true)
Future<GetLocationsResponse> fetchCities(Ref ref, int countryId)
@Riverpod(keepAlive: true)
Future<GetLocationsResponse> fetchLocations(Ref ref, {int countryId = 1, int cityId = 34})final cities = await ref.watch(fetchCitiesProvider(1));final districts = await locationRepository.getDistricts(cityId: selectedCity.id);await LocationImportService.importLocationsFromAssets();address_input_screen.dart: Updated to usefetchCitiesProvider(1)instead offetchLocationsProvider()- Location selection now properly loads Turkish provinces and districts
- Uses
assets/il-ilce.jsoncontaining Turkish provinces and districts - Asset registered in
pubspec.yaml
- No composite indexes needed (queries are simple)
- Uses batch writes for efficiency
- All queries sorted in memory to avoid index requirements
Use the LocationTestPage to manually test import functionality:
- Import locations
- Force re-import
- Clear all location data
- Add support for other countries
- Implement district-level data from JSON if available
- Add location search functionality
- Cache frequently accessed locations locally