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<RequestData> interceptRequest({RequestData data}) async {
   print(data.toString());
   return data;
 }

 @override
 Future<ResponseData> interceptResponse({ResponseData data}) async {
     print(data.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 RequestData data}) Future<RequestData>
interceptResponse({required ResponseData data}) Future<ResponseData>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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