I think you are looking for this
var cl = new HttpClient();
cl.badCertificateCallback = () => print(x);
dartdoc of badCertificateCallback
* Sets a callback that will decide whether to accept a secure connection
* with a server certificate that cannot be authenticated by any of our
* trusted root certificates.