ChopperClient class

ChopperClient is the main class of the Chopper API.

It manages registered services, encodes and decodes data, and intercepts requests and responses.

Constructors

ChopperClient({String baseUrl = '', Client? client, Iterable interceptors = const [], Authenticator? authenticator, Converter? converter, ErrorConverter? errorConverter, Iterable<ChopperService> services = const []})
Creates and configures a ChopperClient.

Properties

authenticator Authenticator?
The Authenticator that can provide reactive authentication for a request.
final
baseUrl String
Base URL of each request of the registered services. E.g., the hostname of your service.
final
converter Converter?
The Converter that handles request and response transformation before the request and response interceptors are called respectively.
final
errorConverter ErrorConverter?
The ErrorConverter that handles response transformation before the response interceptors are called, but only on error responses (statusCode < 200 || statusCode >= 300).
final
hashCode int
The hash code for this object.
no setterinherited
httpClient → Client
The http.Client used to make network calls.
final
onRequest Stream<Request>
A stream of processed Requests, as in after all Converters, and RequestInterceptors have been run.
no setter
onResponse Stream<Response>
A stream of processed Responses, as in after all Converters and ResponseInterceptors have been run.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

delete<BodyType, InnerType>(String url, {Map<String, String> headers = const {}, Map<String, dynamic> parameters = const {}, String? baseUrl}) Future<Response<BodyType>>
Makes a HTTP DELETE request using the send function.
dispose() → void
Disposes this ChopperClient to clean up memory.
get<BodyType, InnerType>(String url, {Map<String, String> headers = const {}, Map<String, dynamic> parameters = const {}, String? baseUrl, dynamic body}) Future<Response<BodyType>>
Makes a HTTP GET request using the send function.
getService<ServiceType extends ChopperService>() → ServiceType
Retrieve any service included in the ChopperClient
Makes a HTTP HEAD request using the send function.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
options<BodyType, InnerType>(String url, {Map<String, String> headers = const {}, Map<String, dynamic> parameters = const {}, String? baseUrl}) Future<Response<BodyType>>
Makes a HTTP OPTIONS request using the send function.
patch<BodyType, InnerType>(String url, {dynamic body, List<PartValue> parts = const [], Map<String, String> headers = const {}, Map<String, dynamic> parameters = const {}, bool multipart = false, String? baseUrl}) Future<Response<BodyType>>
Makes a HTTP PATCH request using the send function.
post<BodyType, InnerType>(String url, {dynamic body, List<PartValue> parts = const [], Map<String, String> headers = const {}, Map<String, dynamic> parameters = const {}, bool multipart = false, String? baseUrl}) Future<Response<BodyType>>
Makes a HTTP POST request using the send function
put<BodyType, InnerType>(String url, {dynamic body, List<PartValue> parts = const [], Map<String, String> headers = const {}, Map<String, dynamic> parameters = const {}, bool multipart = false, String? baseUrl}) Future<Response<BodyType>>
Makes a HTTP PUT request using the send function.
send<BodyType, InnerType>(Request request, {ConvertRequest? requestConverter, ConvertResponse? responseConverter}) Future<Response<BodyType>>
Sends a pre-build Request, applying all provided Interceptors and Converters.
toString() String
A string representation of this object.
inherited

Operators

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