getOptionWithToken method
Helper method to generate request options with authentication headers.
Implementation
Future<Options> getOptionWithToken({Map<String, String?>? headers}) async {
final Map<String, String?> headers0 = {
HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8',
'app_version': appVersion,
'platform': platform,
'app_id': appId,
};
if (headers != null) {
headers0.addAll(headers);
}
/// Get the `AuthInterceptor` instance
final authInterceptor =
_dio.interceptors.whereType<AuthInterceptor>().firstOrNull;
if (authInterceptor != null) {
/// Retrieve the [header] through the callback
final Map<String, String>? headerInfo = authInterceptor.headerCallback();
if (headerInfo != null) {
headers0.addAll(headerInfo);
}
}
return Options(headers: headers0);
}