chopper library Null safety

Chopper is an http client generator using source_gen and inspired by Retrofit.

Getting Started

Classes

Authenticator
This method should return a Request that includes credentials to satisfy an authentication challenge received in response. It should return null if the challenge cannot be satisfied.
Body
Declares the Body of Post, Put, and Patch requests
ChopperApi
Defines a Chopper API.
ChopperClient
ChopperClient is the main class of the Chopper API.
ChopperService
A marker and helper class used by chopper_generator to generate network call implementations.
Converter
An interface for implementing request and response converters.
CurlInterceptor
A RequestInterceptor implementation that prints a curl request equivalent to the network call channeled through it for debugging purposes.
Delete
Defines a method as an HTTP DELETE request.
ErrorConverter
An interface for implementing error response converters.
FactoryConverter
Defines custom Converter methods for a single network API endpoint. See ConvertRequest, ConvertResponse.
Field
Defines a field for a x-www-form-urlencoded request. Automatically binds to the name of the method parameter.
FieldMap
Provides field parameters of a request as Map<String, dynamic>.
FormUrlEncodedConverter
A Converter implementation that converts only Requests having a Map as their body.
Get
Defines a method as an HTTP GET request.
Defines a method as an HTTP HEAD request.
Passes a value to the header of the request.
HeadersInterceptor
A RequestInterceptor that adds headers to every request.
HttpLoggingInterceptor
A RequestInterceptor and ResponseInterceptor implementation which logs HTTP request and response data.
HttpMethod
JsonConverter
A Converter implementation that calls json.encode on Requests and json.decode on Responses using the dart:convert package's utf8 and json utilities.
Method
Defines an HTTP method.
Multipart
Defines a multipart request.
Options
Part
Use Part to define a part of a Multipart request.
PartFile
Use PartFile to define a file field for a Multipart request.
PartFileMap
Provides partFile parameters of a request as PartValueFile.
PartMap
Provides part parameters of a request as PartValue.
PartValue<T>
Represents a part in a multipart request.
PartValueFile<T>
Represents a file part in a multipart request.
Patch
Defines a method as an HTTP PATCH request. Use the Body annotation to pass data to send.
Path
Provides a parameter in the url.
Post
Defines a method as an HTTP POST request.
Put
Defines a method as an HTTP PUT request.
Query
Provides the query parameters of a request.
QueryMap
Provides query parameters of a request as Map<String, dynamic>.
Request
This class represents an HTTP request that can be made with Chopper.
RequestInterceptor
An interface for implementing request interceptors.
Response<BodyType>
A http.BaseResponse wrapper representing a response of a Chopper network call.
ResponseInterceptor
An interface for implementing response interceptors.

Constants

body → const Body
Body()
contentTypeKey → const String
'content-type'
formEncodedHeaders → const String
'application/x-www-form-urlencoded'
jsonApiHeaders → const String
'application/vnd.api+json'
jsonHeaders → const String
'application/json'
multipart → const Multipart

Properties

allowedInterceptorsType List<Type>
chopperLogger Logger
final

Functions

applyHeader(Request request, String name, String value, {bool override = true}) Request
Creates a new Request by copying request and adding a header with the provided key name and value value to the result.
applyHeaders(Request request, Map<String, String> headers, {bool override = true}) Request
Creates a new Request by copying request and adding the provided headers to the result.
buildUri(String baseUrl, String url, Map<String, dynamic> parameters) Uri
Builds a valid URI from baseUrl, url and parameters.
isTypeOf<ThisType, OfType>() bool
toHttpRequest(dynamic body, String method, Uri uri, Map<String, String> headers) Future<Request>
toMultipartRequest(List<PartValue> parts, String method, Uri uri, Map<String, String> headers) Future<MultipartRequest>
toStreamedRequest(Stream<List<int>> bodyStream, String method, Uri uri, Map<String, String> headers) Future<StreamedRequest>

Typedefs

ConvertRequest = FutureOr<Request> Function(Request request)
A function that should convert the body of a Request to the HTTP representation.
ConvertResponse<T> = FutureOr<Response> Function(Response response)
A function that should convert the body of a Response from the HTTP representation to a Dart object.
DynamicResponseInterceptorFunc = FutureOr<Response> Function(Response response)
RequestInterceptorFunc = FutureOr<Request> Function(Request request)
ResponseInterceptorFunc1 = FutureOr<Response<BodyType>> Function<BodyType>(Response<BodyType> response)
ResponseInterceptorFunc2 = FutureOr<Response<BodyType>> Function<BodyType, InnerType>(Response<BodyType> response)