Client class abstract

An HTTP client acts as a single point from which many requests can be constructed. All requests constructed from a client will inherit headers, the withCredentials flag, and the timeoutThreshold.

On the server, the Dart VM will also be able to take advantage of cached network connections between requests that share a client.

TODO: Remove this class in 4.0.0 and move the abstract definition into the HttpClient class.

Implementers
Annotations
  • @Deprecated(v3Deprecation + 'Use `HttpClient` instead.')

Constructors

Client({TransportPlatform? transportPlatform})
factory

Properties

autoRetry ↔ AutoRetryConfig
Configuration of automatic request retrying for failed requests. Use this object to enable or disable automatic retrying, configure the criteria that determines whether or not a request should be retried, as well as the number of retries to attempt.
getter/setter pair
baseUri Uri?
A base URI that all requests from this client should inherit.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
Get and set request headers that will be applied to all requests created by this HTTP client.
getter/setter pair
isClosed bool
Whether or not the HTTP client has been closed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeoutThreshold Duration?
Amount of time to wait for a request created by this client to finish before canceling it and considering it "timed out" (results in a RequestException being thrown).
getter/setter pair
withCredentials bool?
Whether or not to send requests from this client with credentials. Only applicable to requests in the browser, but does not adversely affect any other platform.
getter/setter pair

Methods

addInterceptor(HttpInterceptor interceptor) → void
close() → void
Closes the client, cancelling or closing any outstanding connections.
newFormRequest() FormRequest
Constructs a new FormRequest that will use this client to send the request. Throws a StateError if this client has been closed.
newJsonRequest() JsonRequest
Constructs a new JsonRequest that will use this client to send the request. Throws a StateError if this client has been closed.
newMultipartRequest() MultipartRequest
Constructs a new MultipartRequest that will use this client to send the request. Throws a StateError if this client has been closed.
newRequest() Request
Constructs a new Request that will use this client to send the request. Throws a StateError if this client has been closed.
newStreamedRequest() StreamedRequest
Constructs a new StreamedRequest that will use this client to send the request. Throws a StateError if this client has been closed.
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