I'm using Dio and its interceptors to handle authentication with my REST API.
After authentication I add a global interceptor like this:
_authInterceptor =
InterceptorsWrapper(onRequest: (RequestOptions options) async {
options.headers.addAll({"Authorization": " Bearer " + token});
return options;
});
_dio.interceptors.add(_authInterceptor);
This adds the header to all further requests with dio nicely. However for some requests (e.g. to external APIs) I want to remove this header, to not share credentials unwillingly with other parties.
I could not find a way in the docs to disable or exclude an interceptor temporarily. Any ideas how to do this?