MessageBuilder.prepareMessageWithMediaType constructor

MessageBuilder.prepareMessageWithMediaType(
  1. MediaSubtype subtype, {
  2. TransferEncoding transferEncoding = TransferEncoding.eightBit,
})

Convenience method to init a message with the specified media subtype

In case you want to use 7bit instead of the default 8bit content transfer encoding, specify the optional transferEncoding.

You can also create a new MessageBuilder and call setContentType with the same effect when using the identical media subtype.

Implementation

factory MessageBuilder.prepareMessageWithMediaType(
  MediaSubtype subtype, {
  TransferEncoding transferEncoding = TransferEncoding.eightBit,
}) {
  final mediaType = subtype.mediaType;
  final builder = MessageBuilder()
    ..setContentType(mediaType)
    ..transferEncoding = transferEncoding;

  return builder;
}