AuthBlocRefreshInterceptor class
A RefreshTokenInterceptor wired to drive AuthBloc's refresh on 401.
On a refresh-triggering response (401 by default), this interceptor runs
AuthBloc's singleflight refresh via AuthBlocRefreshStrategy, then retries
the failed request with the new access token.
final dio = Dio();
final fetchBloc = FetchBloc(storageBloc: storageBloc, dio: dio);
fetchBloc.send(InitializeFetchEvent(
config: FetchConfig(baseUrl: 'https://api.example.com'),
interceptors: [
AuthBlocAuthInterceptor(authBloc),
AuthBlocRefreshInterceptor(authBloc, dio: dio),
],
));
Constructors
Properties
- dio → Dio
-
The Dio instance for retrying requests.
finalinherited
-
getAccessToken
→ Future<
String?> Function()? -
Function to get the current access token for retry.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- headerName → String
-
Header name for authorization.
finalinherited
-
onRefreshFailed
→ Future<
void> Function()? -
Called when token refresh fails (e.g., to trigger logout).
finalinherited
- prefix → String
-
Prefix before the token value.
finalinherited
- priority → int
-
Priority determines execution order.
no setterinherited
-
refreshOnStatusCodes
→ Set<
int> -
Status codes that trigger a refresh attempt.
finalinherited
-
refreshToken
→ Future<
String?> Function() -
Function to refresh the token. Returns new access token or null on failure.
finalinherited
- 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 error) → Future -
Called on error.
inherited
-
onRequest(
RequestOptions options) → Future< RequestOptions> -
Called before request is sent.
inherited
-
onResponse(
Response response) → Future< Response> -
Called after successful response.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited