InterceptorContract class abstract

Interceptor interface to create custom Interceptor for http. Extend this class and override the functions that you want to intercept.

Intercepting: You have to implement two functions, interceptRequest and interceptResponse.

Example (Simple logging):

class LoggingInterceptor implements InterceptorContract {
 @override
 Future<BaseRequest> interceptRequest({required BaseRequest request}) async {
   print(request.toString());
   return data;
 }

 @override
 Future<BaseResponse> interceptResponse({required BaseResponse response}) async {
     print(response.toString());
     return data;
 }

}

Constructors

InterceptorContract()

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

interceptRequest({required BaseRequest request}) Future<BaseRequest>
interceptResponse({required BaseResponse response}) Future<BaseResponse>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldInterceptRequest() Future<bool>
shouldInterceptResponse() Future<bool>
toString() String
A string representation of this object.
inherited

Operators

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