getPartWithContentId method
Retrieves the part with the specified Content-ID cid
.
Implementation
MimePart? getPartWithContentId(String cid) {
var contentId = cid;
if (!contentId.startsWith('<')) {
contentId = '<$contentId>';
}
contentId = contentId.toLowerCase();
final allParts = allPartsFlat;
for (final part in allParts) {
final partCid = part._getLowerCaseHeaderValue('content-id');
if (partCid != null && partCid.toLowerCase() == cid) {
return part;
}
}
final body = this.body;
if (body != null) {
final bodyPart = body.findFirstWithContentId(cid);
if (bodyPart != null) {
return getPart(bodyPart.fetchId!);
}
}
return null;
}