decodeBinary method Null safety

  1. @override
Uint8List decodeBinary(
  1. String? contentTransferEncoding
)
override

Decodes the data represented by the mime data

Implementation

@override
Uint8List decodeBinary(String? contentTransferEncoding) {
  contentTransferEncoding = contentTransferEncoding?.toLowerCase();
  if (_bodyStartIndex == null ||
      // do not try to decode textual content:
      contentTransferEncoding == '7bit' ||
      contentTransferEncoding == '8bit' ||
      contentTransferEncoding == 'quoted-printable') {
    return _bodyData;
  }
  // even with a 'binary' content transfer encoding there are \r\n chararacters that need to be handled,
  // so translate to text first
  final dataText = String.fromCharCodes(_bodyData);
  return MailCodec.decodeBinary(dataText, contentTransferEncoding);
}