chopper library

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

Getting Started

Classes

Body
Declare Body of Post, Put, Patch request [...]
ChopperApi
Define a Chopper API [...]
ChopperClient
ChopperClient is the main class of the Chopper API Used to manager services, encode data, intercept request, response and error.
ChopperService
Used by generator to generate apis
Converter
Converter is is used to convert body of Request or Response convertRequest is call before RequestInterceptor and convertResponse just after the http response, before ResponseInterceptor. [...]
CurlInterceptor
Interceptor that print a curl request thanks @edwardaux
Delete
Define a method as an Http DELETE request
ErrorConverter
FactoryConverter
Field
Define fields for a x-www-form-urlencoded request. Automatically bind to the name of the method parameter. [...]
FileField
Use to define a file field for Multipart request [...]
FormUrlEncodedConverter
Get
Define a method as an Http GET request
Define a method as an Http HEAD request
Pass value to header of the request Use the name of the method parameter or the name specified in the annotation. [...]
HeadersInterceptor
Add headers to each request
HttpLoggingInterceptor
HttpMethod
JsonConverter
json.encode on Request and json.decode on Request Also add application/json header to each request [...]
Method
Define an HTTP method Must be use inside a ChopperApi definition. [...]
Multipart
Define a multipart request [...]
Part
Use to define part of Multipart request All values will are converted to String using toString method [...]
PartFile
Use to define a file field for Multipart request [...]
PartValue<T>
PartValueFile<T>
Patch
Define a method as an Http PATCH request use Body annotation to determine data to send
Path
Provide parameter inside url. [...]
Post
Define a method as an Http POST request use Body annotation to determine data to send
Put
Define a method as an Http PUT request use Body annotation to determine data to send
Query
Provide query parameters of a request. [...]
QueryMap
Provide query parameters of a request as Map<String, dynamic> [...]
Request
RequestInterceptor
Interface to implements a request interceptor. Not recommended to modify body inside interceptor, see Converter to encode body request. [...]
Response<BodyType>
ResponseInterceptor
Interface to implements a response interceptor. Not recommended to modify body inside interceptor, see Converter to decode body response. [...]

Constants

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

Properties

allowedInterceptorsType → List<Type>
@visibleForTesting, final
chopperLogger Logger
final

Functions

applyHeader(Request request, String name, String value, {bool override: true}) Request
Apply value to the header field name of the request if override is true, it will erase already present headers with the new value [...]
applyHeaders(Request request, Map<String, String> headers, {bool override: true}) Request
Apply given headers to the request if override is true, it will erase already present headers with the new value [...]
buildUri(String baseUrl, String url, Map<String, dynamic> parameters) → Uri
isTypeOf<ThisType, OfType>() → bool
responseIsSuccessful(int statusCode) → 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<BaseRequest>

Typedefs

ConvertRequest(Request request) Request
ConvertResponse<T>(Response response) Response
DynamicResponseInterceptorFunc(Response response) → FutureOr<Response>
RequestInterceptorFunc(Request request) → FutureOr<Request>
ResponseInterceptorFunc1(Response<BodyType> response) → FutureOr<Response<BodyType>>
ResponseInterceptorFunc2(Response<BodyType> response) → FutureOr<Response<BodyType>>