StringHttpMessageConverter class final

Jetleaf’s built-in AbstractHttpMessageConverter implementation for handling plain text (text/plain) HTTP payloads.

This converter supports:

Supported Media Types

  • text/plain

Example

final converter = StringHttpMessageConverter();
final message = HttpInputMessage.fromBody('Hello Jetleaf');
final result = await converter.read(String, message);
print(result); // "Hello Jetleaf"

Design Notes

  • Registered by default in Jetleaf’s message conversion chain.
  • Delegated by HttpMessageConverters for plain text serialization.
  • Uses UTF-8 encoding for both read and write operations.
Inheritance

Constructors

StringHttpMessageConverter()
Jetleaf’s built-in AbstractHttpMessageConverter implementation for handling plain text (text/plain) HTTP payloads.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addDefaultHeaders(HttpHeaders headers, MediaType? contentType) → void
Adds default headers to the HTTP message if not already present.
inherited
addSupportedMediaType(MediaType type) → void
Adds a media type to the list of supported types.
inherited
canRead(Class type, [MediaType? mediaType]) → bool
Determines whether this converter can deserialize the given type from the specified media type.
inherited
canWrite(Class type, [MediaType? mediaType]) → bool
Determines whether this converter can serialize the given type to the specified media type.
inherited
equalizedProperties() → List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
getClassSupportedMediaTypes(Class<String> type) → List<MediaType>
Returns the media types specifically supported for a given class type.
inherited
getDefaultEncoding() → Encoding
Returns the default character encoding used by this converter.
inherited
getSupportedMediaTypes() → List<MediaType>
Returns the list of media types this converter supports by default.
inherited
matchesType(Class type) → bool
Returns whether the given type matches this filter's criteria.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(Class<String> type, HttpInputMessage inputMessage) → Future<String>
Deserializes an HTTP input message to a Dart object of type T.
inherited
readInternal(Class<String> type, HttpInputMessage inputMessage) → Future<String>
Template method for reading and deserializing HTTP input.
override
removeSupportedMediaType(MediaType type) → void
Removes a media type from the list of supported types.
inherited
resolveRequestEncoding(HttpInputMessage inputMessage) → Encoding
Resolves the appropriate character encoding for reading the request body.
inherited
resolveResponseEncoding(HttpOutputMessage outputMessage) → Encoding
Resolves the appropriate character encoding for writing the response body.
inherited
setDefaultEncoding(Encoding encoding) → void
Sets the default character encoding for this converter.
inherited
setSupportedMediaTypes(List<MediaType> types) → void
Replaces the current supported media types with the provided list.
inherited
toString() → String
A string representation of this object.
inherited
write(String object, MediaType? contentType, HttpOutputMessage outputMessage) → Future<void>
Serializes a Dart object to an HTTP output message.
inherited
writeInternal(String object, HttpOutputMessage outputMessage) → Future<void>
Template method for serializing an object to an HTTP output message.
override

Operators

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