refactor: normalize state codes to uppercase in location parts and agent details
This commit is contained in:
@@ -181,7 +181,7 @@ class AgentDetailState {
|
||||
fvStates = _extractAllValuesAsList(fv);
|
||||
}
|
||||
}
|
||||
if (fvStates != null) parts.addAll(fvStates);
|
||||
if (fvStates != null) parts.addAll(fvStates.map(_normalizeStateCode));
|
||||
if (fvCities != null) {
|
||||
for (final c in fvCities) {
|
||||
if (!parts.any((p) => p.toLowerCase() == c.toLowerCase())) {
|
||||
@@ -193,7 +193,7 @@ class AgentDetailState {
|
||||
// 2. Fallback: agent model direct state/city
|
||||
if (parts.isEmpty && agent != null) {
|
||||
if (agent!.state != null && agent!.state!.isNotEmpty) {
|
||||
parts.add(agent!.state!);
|
||||
parts.add(_normalizeStateCode(agent!.state!));
|
||||
}
|
||||
if (agent!.city != null && agent!.city!.isNotEmpty) {
|
||||
parts.add(agent!.city!);
|
||||
@@ -211,6 +211,13 @@ class AgentDetailState {
|
||||
return parts;
|
||||
}
|
||||
|
||||
/// Uppercase 2-letter US state codes (e.g. "co" → "CO"); leave full state names alone.
|
||||
String _normalizeStateCode(String raw) {
|
||||
final trimmed = raw.trim();
|
||||
if (trimmed.length == 2) return trimmed.toUpperCase();
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
/// Combined location text for single-line display.
|
||||
String get locationText {
|
||||
final parts = locationParts;
|
||||
|
||||
Reference in New Issue
Block a user