encodeText method Null safety

String encodeText(
  1. String text,
  2. TransferEncoding transferEncoding,
  3. [CharacterSet characterSet = CharacterSet.utf8]

Encodes the specified text with given transferEncoding.

Specify the characterSet when a different character set than UTF-8 should be used.


static String encodeText(String text, TransferEncoding transferEncoding,
    [CharacterSet characterSet = CharacterSet.utf8]) {
  switch (transferEncoding) {
    case TransferEncoding.quotedPrintable:
      return MailCodec.quotedPrintable
          .encodeText(text, codec: getCodec(characterSet));
    case TransferEncoding.base64:
      return MailCodec.base64.encodeText(text, codec: getCodec(characterSet));
      return MailCodec.wrapText(text, wrapAtWordBoundary: true);