Installation

    dependencies:
        dio_api_version_interceptor: [version]

Usage

Import the library

import 'package:dio_api_version_interceptor/dio_api_version_interceptor.dart';

You can use an explicit call to the endpoint to check the version compatibility.

 final dio = Dio(BaseOptions(baseUrl: 'https://run.mocky.io'));
 return dio.checkCompatibilityMapped(
    path: '/v3/bb2dd989-d94a-46b8-9cdc-76d32a979dc3',
    appVersion: appVersion,
  );

Or you can use the Header Interceptor to check version on every response

 
 final headerResultController =
    StreamController<CompatibilityResult>;
 ...
 final interceptor = ApiVersionHeaderInterceptor(
    streamController: headerResultController,
    appVersion: appVersion,
    minSupportedVersion: VersionSupportType.minor,
  );
  dio = Dio(BaseOptions(baseUrl: 'https://run.mocky.io'))
    ..interceptors.add(interceptor);

  return headerResultController.stream;

Libraries

dio_api_version_interceptor
Support for doing something awesome. [...]