CallbackInterceptor class

A simple interceptor that can be created with function callbacks

This is useful for creating quick interceptors without having to create a full class that extends FittorInterceptor.

Example:

final loggingInterceptor = CallbackInterceptor(
  onRequest: (request) async {
    print('Sending request to ${request.url}');
    return request;
  },
  onResponse: (response) async {
    print('Received response: ${response.statusCode}');
    return response;
  },
);
Inheritance

Constructors

CallbackInterceptor.new({Future<FittorRequest> onRequest(FittorRequest)?, Future<FittorResponse> onResponse(FittorResponse)?, Future onError(dynamic, StackTrace)?})
Creates a callback-based interceptor

Properties

hashCode int
The hash code for this object.
no setterinherited
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(dynamic error, StackTrace stackTrace) Future
Called when an error occurs during request processing
override
onRequest(FittorRequest request) Future<FittorRequest>
Called before a request is sent
override
onResponse(FittorResponse response) Future<FittorResponse>
Called after a successful response is received
override
toString() String
A string representation of this object.
inherited

Operators

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