0

i am trying to fix CERTIFICATE_VERIFY_FAILED (in development mode), it seems this answer is good https://stackoverflow.com/a/61312927/8010101, so i tried it, but this error show up

A value of type 'bool Function(X509Certificate, String, int)' can't be assigned to a variable of type 'bool Function(X509Certificate, String, int)?'.

this is my code from main.dart

class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext? context) {
    return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
  }
}
GNassro
  • 891
  • 1
  • 10
  • 23
  • There should be nothing wrong with the code you've shown. The error message, assuming you copied and pasted it exactly, does not make any sense (unless you somehow have multiple types named `X509Certificate`, `String`, or `int`). I copied and pasted your code and cannot reproduce your problem. Can you provide a *complete* example that reproduces it? – jamesdlin Apr 17 '22 at 17:03
  • i don't know what is the problem, when i put that code in the main.dart file, the error show up, but when i put it in new file, it work fine – GNassro Apr 17 '22 at 18:54
  • Show the rest of your `main.dart` file. – jamesdlin Apr 17 '22 at 18:56
  • @jamesdlin thanks for trying to help, the problem in main.dart because of import `flutter_inappwebview` package – GNassro Apr 19 '22 at 09:57

1 Answers1

1

I faced the same problem when I imported inappwebview to main.dart.

What helped me is changing the import to:

import 'package:flutter_inappwebview/flutter_inappwebview.dart' as inapp;

And when I use inappwebview:

await inapp.InAppWebViewController.setWebContentsDebuggingEnabled(true);
Anthonio
  • 56
  • 2