RequestBody class

Represents a request payload sent through the SDK call API.

Use the named constructors to describe the payload shape expected by the underlying HTTP client.

final body = RequestBody.multipart(
  fields: {'name': 'avatar'},
  files: {
    'file': BodyFile(
      filename: 'avatar.png',
      bytes: bytes,
      contentType: 'image/png',
    ),
  },
);

Constructors

RequestBody.bytes(Uint8List bytes, {String contentType = 'application/octet-stream'})
Creates a raw byte body.
factory
RequestBody.formUrlEncoded(Map<String, dynamic> data)
Creates an application/x-www-form-urlencoded style body description.
factory
RequestBody.json(dynamic json)
Creates a JSON body.
factory
RequestBody.multipart({Map<String, dynamic>? fields, Map<String, BodyFile>? files})
Creates a multipart body with optional fields and files.
factory
RequestBody.none()
Creates an empty request body.
const
RequestBody.text(String text, {String? contentType})
Creates a plain-text body.
factory

Properties

contentType String?
Optional content type metadata for text or byte payloads.
final
fields Map<String, dynamic>?
Form fields used for multipart requests.
final
files Map<String, BodyFile>?
Multipart files keyed by field name.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type BodyType
The body encoding requested by the caller.
final
value → dynamic
The primary body value for non-multipart requests.
final

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