chopper library
Chopper is an http client generator using source_gen and inspired by Retrofit.
Classes
- Authenticator
- Handles authentication challenges raised by the ChopperClient.
- Body
- Declares the Body of Post, Put, and Patch requests
-
Chain<
BodyType> - A single chain instance in the chain of interceptors that is called in order to process requests and responses.
- ChopperApi
- Defines a Chopper API.
- ChopperClient
- ChopperClient is the main class of the Chopper API.
- ChopperLogRecord
- 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 Interceptor 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>.
- FormUrlEncoded
- Denotes that the request body will use form URL encoding. Fields should be declared as parameters and annotated with Field/FieldMap.
- FormUrlEncodedConverter
- A Converter implementation that converts only Requests having a Map as their body.
- Get
- Defines a method as an HTTP GET request.
- Head
- Defines a method as an HTTP HEAD request.
- Header
- Passes a value to the header of the request.
- HeadersInterceptor
- A Interceptor that adds headers to every request.
- HttpLoggingInterceptor
- A Interceptor implementation which logs HTTP request and response data.
- HttpMethod
- Interceptor
- The interface for implementing interceptors. Interceptors are used for intercepting request, responses and preforming operations on them.
- JsonConverter
-
A Converter implementation that calls
json.encode
on Requests andjson.decode
on Responses using the dart:convert package's utf8 and json utilities. - Method
- Defines an HTTP method.
- Multipart
- Defines a multipart request.
- Options
- Defines a method as an HTTP OPTIONS request.
- 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 PartValue 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.
-
Response<
BodyType> -
A
http.BaseResponse
wrapper representing a response of a Chopper network call. - Tag
- Adds the argument instance as a request tag.
Enums
- Level
- ListFormat
- An enum of all available list format options.
Mixins
- MockChopperClientMixin
- ChopperClient mixin for the purposes of creating mocks using a mocking framework such as Mockito or Mocktail.
- MockChopperLogRecordMixin
- ChopperLogRecord mixin for the purposes of creating mocks using a mocking framework such as Mockito or Mocktail.
-
MockPartValueFileMixin<
T> - PartValueFile mixin for the purposes of creating mocks using a mocking framework such as Mockito or Mocktail.
-
MockPartValueMixin<
T> - PartValue mixin for the purposes of creating mocks using a mocking framework such as Mockito or Mocktail.
- MockRequestMixin
- Request mixin for the purposes of creating mocks using a mocking framework such as Mockito or Mocktail.
-
MockResponseMixin<
BodyType> - Response mixin for the purposes of creating mocks using a mocking framework such as Mockito or Mocktail.
Extensions
Constants
- body → const Body
- Declares the Body of Post, Put, and Patch requests
- chopperApi → const ChopperApi
- Defines a Chopper API.
- contentTypeKey → const String
- delete → const Delete
- Defines a method as an HTTP DELETE request.
- factoryConverter → const FactoryConverter
- Defines custom Converter methods for a single network API endpoint. See ConvertRequest, ConvertResponse.
- field → const Field
-
Defines a field for a
x-www-form-urlencoded
request. Automatically binds to the name of the method parameter. - fieldMap → const FieldMap
- Provides field parameters of a request as Map<String, dynamic>.
- formEncodedHeaders → const String
- formUrlEncoded → const FormUrlEncoded
- Denotes that the request body will use form URL encoding. Fields should be declared as parameters and annotated with Field/FieldMap.
- get → const Get
- Defines a method as an HTTP GET request.
- head → const Head
- Defines a method as an HTTP HEAD request.
- header → const Header
- Passes a value to the header of the request.
- jsonApiHeaders → const String
- jsonHeaders → const String
- multipart → const Multipart
- Defines a multipart request.
- options → const Options
- Defines a method as an HTTP OPTIONS request.
- part → const Part
- Use Part to define a part of a Multipart request.
- partFile → const PartFile
- Use PartFile to define a file field for a Multipart request.
- partFileMap → const PartFileMap
- Provides partFile parameters of a request as PartValueFile.
- partMap → const PartMap
- Provides part parameters of a request as PartValue.
- patch → const Patch
- Defines a method as an HTTP PATCH request. Use the Body annotation to pass data to send.
- path → const Path
- Provides a parameter in the url.
- post → const Post
- Defines a method as an HTTP POST request.
- put → const Put
- Defines a method as an HTTP PUT request.
- query → const Query
- Provides the query parameters of a request.
- queryMap → const QueryMap
- Provides query parameters of a request as Map<String, dynamic>.
- tag → const Tag
- Adds the argument instance as a request tag.
Properties
- 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 keyname
and valuevalue
to the result. -
applyHeaders(
Request request, Map< String, String> headers, {bool override = true}) → Request -
Creates a new Request by copying
request
and adding the providedheaders
to the result. -
isTypeOf<
ThisType, OfType> () → bool
Typedefs
-
AuthenticationCallback
= FutureOr<
void> Function(Request request, Response response, [Request? originalRequest]) -
Callback that is called when an authentication challenge is received
based on the given
request
,response
, and optionally theoriginalRequest
. -
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)T> > - A function that should convert the body of a Response from the HTTP representation to a Dart object.
Exceptions / Errors
- ChopperException
- An exception thrown when something goes wrong with Chopper.
- ChopperHttpException
- An exception thrown when a Response is unsuccessful < 200 or > 300.