onResponse method
The callback will be executed on success.
If you want to continue the response, call handler.next
.
If you want to complete the response with some custom data directly,
you can resolve a Response
object with handler.resolve
and other
response interceptor(s) will not be executed.
If you want to complete the response with an error message,
you can reject a DioError
object with handler.reject
.
Implementation
@override
void onResponse(Response response, ResponseInterceptorHandler handler) {
if (response.headers.map.containsKey(headerApiVersionKey)) {
final apiVersion = response.headers.map[headerApiVersionKey]!.first;
final apiVersionParts = apiVersion.split('.').map((e) => int.parse(e));
final appVersionParts = appVersion.split('.').map((e) => int.parse(e));
streamController.add(
_isSupportedVersion(
apiVersionParts: apiVersionParts,
appVersionParts: appVersionParts,
minSupportedVersion: minSupportedVersion,
)
? CompatibleVersion(apiVersion, appVersion)
: IncompatibleVersion(apiVersion, appVersion),
);
}
super.onResponse(response, handler);
}