getChildPart method

BodyPart? getChildPart(
  1. String partFetchId
)

Implementation

BodyPart? getChildPart(String partFetchId) {
  final _fetchId = partFetchId.contains('.TEXT')
      ? fetchId
      : fetchId?.replaceAll('.TEXT', '');
  // Handle the searching for the .HEADER part of a nested rfc822 part
  if (_fetchId == partFetchId ||
      _fetchId == partFetchId.replaceFirst('.HEADER', '')) {
    return this;
  }
  if (parts != null) {
    for (final part in parts!) {
      final match = part.getChildPart(partFetchId);
      if (match != null) {
        return match;
      }
    }
  }
  return null;
}