BodyType class

A body type that combines MIME type and encoding information.

This class encapsulates both the MIME type (what kind of content this is) and the optional encoding (how text content is encoded into bytes).

Examples:

// Text content with encoding
const textType = BodyType(
  mimeType: MimeType.plainText,
  encoding: utf8,
);
print(textType.toHeaderValue()); // "text/plain; charset=utf-8"

// Binary content without encoding
const binaryType = BodyType(mimeType: MimeType.octetStream);
print(binaryType.toHeaderValue()); // "application/octet-stream"

// JSON content
const jsonType = BodyType(
  mimeType: MimeType.json,
  encoding: utf8,
);
print(jsonType.toHeaderValue()); // "application/json; charset=utf-8"

Constructors

BodyType({required MimeType mimeType, Encoding? encoding})
const

Properties

encoding Encoding?
The encoding of the body.
final
hashCode int
The hash code for this object.
no setterinherited
mimeType MimeType
The mime type of the body.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toHeaderValue() String
Returns the value to use for the Content-Type header.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited