ResponseType enum

author: ZhengZaiHong email:1096877329@qq.com date: 2025-01-31 describe: 响应类型枚举 Response type enumeration.

Defines how the response body should be parsed by the adapter. Different adapters may handle these types differently, but the semantic meaning remains consistent.

Inheritance
Available extensions

Values

json → const ResponseType

Parse response as JSON (default)

The response body will be automatically parsed as JSON. This is the most common response type for REST APIs.

Example:

RxNet.get()
  .setPath("/users")
  .setResponseType(ResponseType.json)
  .request();
stream → const ResponseType

Return response as a stream

The response body will be returned as a stream of bytes. Useful for large files or real-time data.

Example:

RxNet.get()
  .setPath("/large-file")
  .setResponseType(ResponseType.stream)
  .request();
plain → const ResponseType

Return response as plain text

The response body will be returned as a plain string. Useful for HTML, XML, or other text-based formats.

Example:

RxNet.get()
  .setPath("/page.html")
  .setResponseType(ResponseType.plain)
  .request();
bytes → const ResponseType

Return response as raw bytes

The response body will be returned as raw bytes (Uint8List). Useful for binary data like images, PDFs, etc.

Example:

RxNet.get()
  .setPath("/image.png")
  .setResponseType(ResponseType.bytes)
  .request();

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
isBytes bool

Available on ResponseType, provided by the ResponseTypeExtension extension

Returns whether this response type is bytes
no setter
isJson bool

Available on ResponseType, provided by the ResponseTypeExtension extension

Returns whether this response type is JSON
no setter
isPlain bool

Available on ResponseType, provided by the ResponseTypeExtension extension

Returns whether this response type is plain text
no setter
isStream bool

Available on ResponseType, provided by the ResponseTypeExtension extension

Returns whether this response type is a stream
no setter
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value String

Available on ResponseType, provided by the ResponseTypeExtension extension

Returns the string representation of the response type
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Constants

values → const List<ResponseType>
A constant List of the values in this enum, in order of their declaration.