getDefaultDio static method
Dio
getDefaultDio()
Implementation
static Dio getDefaultDio() {
Dio result = Dio(BaseOptions(
connectTimeout: Duration(seconds: 10),
receiveTimeout: Duration(seconds: 10)
));
final adapter = result.httpClientAdapter as IOHttpClientAdapter;
adapter.createHttpClient = () {
HttpClient client = HttpClient(context: null);
if ((ApiConfig.proxy ?? '').isNotEmpty) {
client.findProxy = (uri) {
return 'PROXY ${ApiConfig.proxy}';
};
}
client.badCertificateCallback =
(X509Certificate cert, String host, int port) {
return true;
};
return client;
};
return result;
}