getAddressSourceString method

String getAddressSourceString(
  1. OrderSourceAddressAddressDetailsInfo? address
)

Implementation

String getAddressSourceString(OrderSourceAddressAddressDetailsInfo? address) {
  if (address == null) {
    return "-";
  }

  List<String> parts = [];

  // Check each field and only add non-null, non-empty values to the list
  // if (address.streetName?.isNotEmpty ?? false) {
  //   parts.add(address.streetName!);
  // }
  if (address.locationName1?.isNotEmpty ?? false) {
    parts.add(address.locationName1!);
  }
  if (address.locationName2?.isNotEmpty ?? false) {
    parts.add(address.locationName2!);
  }
  if (address.locationName3?.isNotEmpty ?? false) {
    parts.add(address.locationName3!);
  }
  if (address.locationName4?.isNotEmpty ?? false) {
    parts.add(address.locationName4!);
  }
  // Join the list with commas, only if there are valid entries
  return parts.isEmpty ? "-" : parts.join(", ");
}