JsonInterceptor<ErrorType> class

Decodes response bodies into typed models using a registry of factories.

JsonInterceptor<ErrorModel>(
  {Post: Post.fromJson, ErrorModel: ErrorModel.fromJson},
  paginationFactory: PaginationModel.fromJson,
)

ErrorType is the model an unsuccessful response's body is decoded into; register a factory for it in jsonFactories as well.

Inheritance

Constructors

JsonInterceptor(Map<Type, JsonFactory> jsonFactories, {JsonFactory<Pagination>? paginationFactory})

Properties

hashCode int
The hash code for this object.
no setterinherited
jsonFactories Map<Type, JsonFactory>
Maps a model type to the function that builds it from a JSON map.
final
paginationFactory JsonFactory<Pagination>?
Builds the Pagination for requests declaring hasPagination: true.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError<ResponseType, InnerType>(ApiResponse<ResponseType, InnerType> response) ApiResponse<ResponseType, InnerType>
Intercepts the error and returns the modified response
override
onRequest<ResponseType, InnerType>(ApiRequest<ResponseType, InnerType> request) FutureOr<ApiRequest<ResponseType, InnerType>>
Intercepts the request and returns the modified request
inherited
onResponse<ResponseType, InnerType>(ApiResponse<ResponseType, InnerType> response) ApiResponse<ResponseType, InnerType>
Intercepts the response and returns the modified response
override
toString() String
A string representation of this object.
inherited

Operators

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