Request & Response Interceptors
Component Detail
Infrastructure
high complexity
Shared Component
mobile
1
Dependencies
1
Dependents
1
Entities
0
Integrations
Description
Flutter-side Dio/HTTP interceptor chain that transparently handles token refresh, retry logic, and error normalization for every outgoing API request. Ensures that expired tokens are refreshed silently, transient network failures are retried, and all API errors are converted into consistent application-level exceptions before reaching feature code.
request-response-interceptors
Responsibilities
- Intercept outgoing requests to attach the current Bearer token
- Detect 401 Unauthorized responses and trigger silent token refresh
- Retry failed requests after successful token refresh
- Normalize API error envelopes into typed Dart exceptions
- Handle network timeouts and connectivity errors uniformly
Interfaces
onRequest(options, handler)
onResponse(response, handler)
onError(error, handler)
refreshAccessToken()
retryRequest(options)
normalizeApiError(response)
isTokenExpired(error)
queueRequestDuringRefresh(options)
flushQueuedRequests(newToken)
clearQueue(error)