placeAddressComponentShort function

String? placeAddressComponentShort(
  1. SeachPlaceResultDetailModel detail,
  2. String type, {
  3. String? orType,
})

Implementation

String? placeAddressComponentShort(
    SeachPlaceResultDetailModel detail, String type,
    {String? orType}) {
  if (detail.addressComponents
          ?.any((e1) => e1.types?.any((e2) => e2 == type) ?? false) ??
      false) {
    return detail.addressComponents!
        .firstWhere((e1) => e1.types!.any((e2) => e2 == type))
        .shortName;
  } else if (orType != null) {
    if (detail.addressComponents
            ?.any((e1) => e1.types?.any((e2) => e2 == orType) ?? false) ??
        false) {
      return detail.addressComponents!
          .firstWhere((e1) => e1.types!.any((e2) => e2 == orType))
          .shortName;
    }
  }
  return null;
}