PersistentUrlInterceptor class
An interceptor that dynamically modifies the base URL for HTTP requests.
This interceptor allows the application to use a persistent base URL stored in local storage, enabling dynamic switching between different API environments (e.g., development, staging, production) without requiring app rebuilds.
How it works:
- Retrieves the stored base API URL from persistent storage
- Replaces the host of the original request URL with the stored host
- Preserves the original path and other URL components
Use Cases:
- Switching between development and production APIs
- Supporting multiple tenants with different API endpoints
- Testing against different server environments
Example:
// Original request: https://api.example.com/v1/users
// Stored base URL: https://staging.example.com
// Final request: https://staging.example.com/v1/users
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(
DioException err, ErrorInterceptorHandler handler) → void -
Called when an exception was occurred during the request.
inherited
-
onRequest(
RequestOptions options, RequestInterceptorHandler handler) → void - Called when the request is about to be sent.
-
onResponse(
Response response, ResponseInterceptorHandler handler) → void -
Called when the response is about to be resolved.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited