addBaseUrlInterceptor method

void addBaseUrlInterceptor()

Adds a base URL interceptor to the Dio instance.

This method adds an interceptor that handles persistent URL configuration, allowing dynamic base URL changes from stored settings. This is particularly useful for apps that need to switch between different API environments.

Platform Support:

  • Native (iOS/Android): Adds the persistent URL interceptor
  • Web: No-op, as web apps typically use fixed base URLs

Implementation

void addBaseUrlInterceptor() {
  if (!kIsWeb) {
    interceptors.add(PersistentUrlInterceptor());
  }
}