getDefaultDio static method

Dio getDefaultDio()

Implementation

static Dio getDefaultDio() {
  Dio result = Dio(BaseOptions(
    connectTimeout: 10000,
    receiveTimeout: 10000,
  ));

  final adapter = result.httpClientAdapter as DefaultHttpClientAdapter;
  adapter.onHttpClientCreate = (client) {
    if ((ApiConfig.proxy ?? '').isNotEmpty) {
      client.findProxy = (uri) {
        return 'PROXY ${ApiConfig.proxy}';
      };
    }

    client.badCertificateCallback =
        (X509Certificate cert, String host, int port) {
      return true;
    };
  };

  return result;
}