ApiInterceptor class abstract
Api interceptor interface.
Every hook returns FutureOr, so an interceptor may be synchronous — just
return the value — or asynchronous, which is what makes an in-band token
refresh possible:
@override
Future<ApiRequest<R, I>> onRequest<R, I>(ApiRequest<R, I> request) async {
final token = await _store.readToken();
return request.copyWith(headers: {'Authorization': 'Bearer $token'});
}
- Implementers
Constructors
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<
ResponseType, InnerType> (ApiResponse< ResponseType, InnerType> response) → FutureOr<ApiResponse< ResponseType, InnerType> > - Intercepts the error and returns the modified response
-
onRequest<
ResponseType, InnerType> (ApiRequest< ResponseType, InnerType> request) → FutureOr<ApiRequest< ResponseType, InnerType> > - Intercepts the request and returns the modified request
-
onResponse<
ResponseType, InnerType> (ApiResponse< ResponseType, InnerType> response) → FutureOr<ApiResponse< ResponseType, InnerType> > - Intercepts the response and returns the modified response
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited