formattedDisplayName property

String get formattedDisplayName

///////// ///////// Gets a formatted address for display, preserving state names

Implementation

// II.D - Formatting Methods
///////////////
/// Gets a formatted address for display, preserving state names
String get formattedDisplayName {
  // If we have a name, prioritize it
  if (name.isNotEmpty) {
    return name;
  }

  // Get clean display parts from the place name
  final displayParts = <String>[];

  // Simplify the full address to avoid overwhelming displays
  final parts = placeName.split(', ');
  if (parts.isNotEmpty) {
    // Always include the first part (POI or address)
    displayParts.add(parts[0]);

    // Include more parts based on available info
    if (parts.length > 1) {
      // Add city
      displayParts.add(parts[1]);

      // Add state if available (try to preserve the state code/name if it's there)
      if (parts.length > 2 && _isStateCode(parts[2])) {
        displayParts.add(parts[2]);
      }
    }
  }

  return displayParts.join(', ');
}