refactor: update location parsing logic to prioritize state before city in profile settings

This commit is contained in:
pradeepkumar
2026-04-11 22:52:19 +05:30
parent 1ef02383a6
commit 1a08730b83

View File

@@ -92,7 +92,7 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
final city = profile['city'] as String? ?? '';
final stateName = profile['state'] as String? ?? '';
final country = profile['country'] as String? ?? '';
final parts = [city, stateName, country].where((s) => s.isNotEmpty);
final parts = [stateName, city, country].where((s) => s.isNotEmpty);
_locationController.text = parts.join(', ');
}
@@ -403,8 +403,9 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
.map((s) => s.trim())
.where((s) => s.isNotEmpty)
.toList();
if (locationParts.isNotEmpty) data['city'] = locationParts[0];
if (locationParts.length > 1) data['state'] = locationParts[1];
// Display order is state first, then city, then country — parse in the same order
if (locationParts.isNotEmpty) data['state'] = locationParts[0];
if (locationParts.length > 1) data['city'] = locationParts[1];
if (locationParts.length > 2) data['country'] = locationParts[2];
}