HttpRequest class

Builder class for constructing and executing HTTP requests.

HttpRequest provides a fluent API for building HTTP requests with support for middleware, query parameters, headers, and various body types including JSON and multipart form data.

Example

final request = HttpRequest(Uri.parse('https://api.calljmp.com/users'))
  .params({'limit': 10, 'offset': 0})
  .use(authMiddleware);

final response = await request.get().json();

Constructors

HttpRequest(Uri _url)
Creates an HttpRequest for the specified URL.

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

delete() HttpResult
Creates an HttpResult for a DELETE request.
get() HttpResult
Creates an HttpResult for a GET request.
Creates an HttpResult for a HEAD request.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
params(Map<String, dynamic> params) HttpRequest
Adds query parameters to the request URL.
patch([dynamic body]) HttpResult
Creates an HttpResult for a PATCH request with optional body.
post([dynamic body]) HttpResult
Creates an HttpResult for a POST request with optional body.
put([dynamic body]) HttpResult
Creates an HttpResult for a PUT request with optional body.
send() Future<StreamedResponse>
Sends the HTTP request and returns the raw response.
toString() String
A string representation of this object.
inherited
use(HttpMiddleware middleware) HttpRequest
Adds middleware to this request.

Operators

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