createHttp function

HttpClient createHttp(
  1. HttpClientCredentials? credentials,
  2. ByteData? certificate,
  3. SecurityContext securityContext
)

Implementation

HttpClient createHttp(HttpClientCredentials? credentials, ByteData? certificate,
    SecurityContext securityContext) {
  HttpClient client = HttpClient();
  if (credentials != null) client.addCredentials(Uri.base, '', credentials);
  client.badCertificateCallback =
      (X509Certificate cert, String host, int port) {
    if (certificate != null) {
      securityContext
          .setTrustedCertificatesBytes(certificate.buffer.asUint8List());
    }
    return true;
  };
  return client;
}