getChildPart method

BodyPart? getChildPart(
  1. String partFetchId
)

Finds the child part matching the 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;
  }
  final parts = this.parts;
  if (parts != null) {
    for (final part in parts) {
      final match = part.getChildPart(partFetchId);
      if (match != null) {
        return match;
      }
    }
  }

  return null;
}