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.

Feature: REST API Backend

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)

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component