AuthorizationInterceptor class
A custom interceptor for handling authorization and response logic in Dio.
This interceptor automatically adds a Bearer token to all outgoing requests
and handles token expiration by removing itself from Dio's interceptors
when a 401 Unauthorized status code is encountered.
Constructors
- AuthorizationInterceptor(Dio dio, String publicKey)
- Constructor to initialize the interceptor with a Dio instance and a public key.
Properties
- dio → Dio
-
The Dio instance used for making HTTP requests.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- publicKey → String
-
The public key or Bearer token used for Merchant authorization.
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(
DioException err, ErrorInterceptorHandler handler) → void -
Called when an exception was occurred during the request.
inherited
-
onRequest(
RequestOptions options, RequestInterceptorHandler handler) → Future - Intercepts and modifies outgoing requests.
-
onResponse(
Response response, ResponseInterceptorHandler handler) → Future - Intercepts and processes incoming responses.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited