createHttp function
HttpClient
createHttp(
- HttpClientCredentials? credentials,
- ByteData? certificate,
- 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;
}