getAlternativePart method

MimePart? getAlternativePart(
  1. MediaSubtype subtype
)

Searches for this the given subtype as a part of a Multipart/Alternative mime part.

This is useful if you want to check for your preferred rendering format present as an alternative.

Implementation

MimePart? getAlternativePart(MediaSubtype subtype) {
  if (mediaType.sub == MediaSubtype.multipartAlternative) {
    return getPartWithMediaSubtype(subtype);
  }
  final mimeParts = parts;
  if (mimeParts != null) {
    for (final mimePart in mimeParts) {
      final match = mimePart.getAlternativePart(subtype);
      if (match != null) {
        return match;
      }
    }
  }
  return null;
}