findFirst method

BodyPart? findFirst(
  1. MediaSubtype subtype
)

Finds the first body part with the given subtype media type.

Implementation

BodyPart? findFirst(MediaSubtype subtype) {
  if (contentType?.mediaType.sub == subtype) {
    return this;
  }
  final parts = this.parts;
  if (parts != null && parts.isNotEmpty) {
    for (final part in parts) {
      final first = part.findFirst(subtype);
      if (first != null) {
        return first;
      }
    }
  }

  return null;
}