getDioClient method
Dio
getDioClient({
- Duration? receiveTimeout,
- Duration? sendTimeout,
- Duration? connectTimeout,
- String baseUrl = '',
- Map<
String, dynamic> ? headers, - List<
Interceptor> ? interceptors, - List<
int> ? trustedCertificateBytes, - List<
String> ? allowedFingerprints,
override
Implementation
@override
Dio getDioClient({
Duration? receiveTimeout,
Duration? sendTimeout,
Duration? connectTimeout,
String baseUrl = '',
Map<String, dynamic>? headers,
List<Interceptor>? interceptors,
List<int>? trustedCertificateBytes,
List<String>? allowedFingerprints,
}) {
assert(trustedCertificateBytes == null || allowedFingerprints == null);
final dio = Dio(
BaseOptions(
receiveTimeout: receiveTimeout,
sendTimeout: sendTimeout,
connectTimeout: connectTimeout,
baseUrl: baseUrl,
headers: headers,
),
);
if (trustedCertificateBytes != null) {
(dio.httpClientAdapter as IOHttpClientAdapter).createHttpClient = () {
final securityContext = SecurityContext();
securityContext.setTrustedCertificatesBytes(trustedCertificateBytes);
final httpClient = HttpClient(context: securityContext);
return httpClient;
};
}
if (allowedFingerprints != null) {
dio.interceptors.add(AllowedSSLFingerprintInterceptor(allowedSHAFingerprints: allowedFingerprints));
}
if (interceptors != null) {
dio.interceptors.addAll(interceptors);
}
return dio;
}