init method

void init({
  1. bool allowBadCertificates = false,
})

Initialize the HTTP client with optimized settings.

Set allowBadCertificates to true only in development environments to bypass SSL certificate verification (e.g. self-signed certificates). Never use this in production as it disables HTTPS security.

Implementation

void init({bool allowBadCertificates = false}) {
  if (allowBadCertificates) {
    final ioClient = HttpClient()
      ..badCertificateCallback = (cert, host, port) => true;
    _client = IOClient(ioClient);
  } else {
    _client = http.Client();
  }
}