refactor: update location parsing logic to prioritize state before city in profile settings
This commit is contained in:
@@ -92,7 +92,7 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
|
|||||||
final city = profile['city'] as String? ?? '';
|
final city = profile['city'] as String? ?? '';
|
||||||
final stateName = profile['state'] as String? ?? '';
|
final stateName = profile['state'] as String? ?? '';
|
||||||
final country = profile['country'] 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(', ');
|
_locationController.text = parts.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,8 +403,9 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
|
|||||||
.map((s) => s.trim())
|
.map((s) => s.trim())
|
||||||
.where((s) => s.isNotEmpty)
|
.where((s) => s.isNotEmpty)
|
||||||
.toList();
|
.toList();
|
||||||
if (locationParts.isNotEmpty) data['city'] = locationParts[0];
|
// Display order is state first, then city, then country — parse in the same order
|
||||||
if (locationParts.length > 1) data['state'] = locationParts[1];
|
if (locationParts.isNotEmpty) data['state'] = locationParts[0];
|
||||||
|
if (locationParts.length > 1) data['city'] = locationParts[1];
|
||||||
if (locationParts.length > 2) data['country'] = locationParts[2];
|
if (locationParts.length > 2) data['country'] = locationParts[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user