Unhandled Exception: HandshakeException: Handshake error in client – (Solved)

Опубликовано: 02 Октябрь 2024
на канале: KDTechs
11,594
99

Exception:

this class is to Unhandled Exception: HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: ok(handshake.cc:354))


Solution:
In your main.dart file, add or import the following class:
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) = true;
}
}

And add to main method:
HttpOverrides.global = new MyHttpOverrides();