10

I use flutter version 2.2.1

File : Main.dart

enter image description here

This is message error enter image description here

How to solve this error?

GPService
  • 169
  • 1
  • 3
  • 10
  • 14
    1. Don't post screenshots of code and messages; those cannot be searched. 2. As shown by the error message, `HttpOverrides.createHttpClient` takes a `SecurityContext?`, not a `SecurityContext`. – jamesdlin Jun 12 '21 at 03:08

3 Answers3

48

Change SecurityContext to SecurityContext?.

Ahmed Soliman
  • 481
  • 3
  • 2
1

Change SecurityContext to SecurityContext?

here is the update code:

class MyHttpOverrides extends HttpOverrides{
  @override
  HttpClient createHttpClient(SecurityContext? context){
    return super.createHttpClient(context)
      ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true;
  }
}
0

HttpClient createHttpClient(SecurityContext? context) { return super.createHttpClient(context) ..badCertificateCallback = (X509Certificate cert, String host, int port) => true }

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 17 '21 at 18:30