如何解决此错误“('HttpClient Function(SecurityContext)') 不是 'HttpOverrides.createHttpClient'”的有效覆盖

问题描述 投票:0回答:3

我使用flutter版本2.2.1

文件:Main.dart

这是消息错误

如何解决这个错误?

flutter dart flutter-dependencies flutter-animation dart-pub
3个回答
47
投票

将 SecurityContext 更改为 SecurityContext?.


1
投票

将 SecurityContext 更改为 SecurityContext?

这是更新代码:

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) { 返回 super.createHttpClient(context) ..badCertificateCallback = (X509Certificate cert,字符串主机,int 端口)=> true }

© www.soinside.com 2019 - 2024. All rights reserved.