ApiClient class

Provides HTTP API methods, with response deserialization.

This client is built to resemble Node's Axios package (https://github.com/axios/axios) by:

  • throwing exceptions if response status codes fall outside of the 2xx range
  • automatically encoding request bodies as JSON

Constructors

ApiClient(Uri baseUrl, {required Client httpClient})
All HTTP methods (get, post, etc.) append their path args to baseUrl in order to build the endpoint URL.

Properties

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

Methods

close() → void
Closes the API client.
delete<ResponseType>(String path, {Map<String, String>? query, Map<String, String>? headers, JsonDeserializer<ResponseType>? responseDeserializer}) Future<ResponseType?>
Performs an HTTP DELETE api call.
get<ResponseType>(String path, {Map<String, String>? query, Map<String, String>? headers, JsonDeserializer<ResponseType>? responseDeserializer}) Future<ResponseType>
Performs an HTTP GET api call.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
post<ResponseType>(String path, {Map<String, String?>? query, dynamic jsonBody, Map<String, String>? headers, JsonDeserializer<ResponseType>? responseDeserializer}) Future<ResponseType>
Performs an HTTP POST api call.
postMultipart<ResponseType>(String path, {required Iterable<MultipartFile> files, Map<String, String>? headers, JsonDeserializer<ResponseType>? responseDeserializer, UploadProgressCallback? onUploadProgress}) Future<ResponseType>
Performs an HTTP POST multipart api call.
put<ResponseType>(String path, {Map<String, String?>? query, dynamic jsonBody, Map<String, String>? headers, JsonDeserializer<ResponseType>? responseDeserializer}) Future<ResponseType>
Performs an HTTP PUT api call.
request<ResponseType>(String method, String path, {Map<String, String?>? query, dynamic jsonBody, Map<String, String>? headers, JsonDeserializer<ResponseType>? responseDeserializer}) Future<ResponseType>
Performs an HTTP request of the specified method.
send<ResponseType>(BaseRequest request, {Map<String, String>? headers, JsonDeserializer<ResponseType>? responseDeserializer}) Future<ResponseType>
toString() String
A string representation of this object.
inherited

Operators

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