Error: The method ‘DioHttpHeaders.add‘ has fewer named arguments than those of overridden method

简介: Error: The method ‘DioHttpHeaders.add‘ has fewer named arguments than those of overridden method

很久没更新dio了,编译时出现以下错误

../../../dev/flutter/.pub-cache/hosted/pub.flutter-io.cn/dio-2.2.2/lib/src/dio_http_headers.dart:55:8: Error: The method 'DioHttpHeaders.add' has fewer named arguments than those of overridden method 'HttpHeaders.add'.
  void add(String name, value) {                                        
       ^                                                                
org-dartlang-sdk:///third_party/dart/sdk/lib/_http/http.dart:698:8: Context: This is the overridden method ('add').
  void add(String name, Object value,                                   
       ^                                                                
../../../dev/flutter/.pub-cache/hosted/pub.flutter-io.cn/dio-2.2.2/lib/src/dio_http_headers.dart:70:8: Error: The method 'DioHttpHeaders.set' has fewer named arguments than those of overridden method 'HttpHeaders.set'.
  void set(String name, Object value) {                                 
       ^                                                                
org-dartlang-sdk:///third_party/dart/sdk/lib/_http/http.dart:707:8: Context: This is the overridden method ('set').
  void set(String name, Object value,                                   
       ^                                                                
                                                                        
                                                                        
FAILURE: Build failed with an exception.     

显示的错误是dio有问题,当前用的版本是2.1.12。

去dio的官网发现是版本问题,更新到最新的3.0重新编译即可,同时注意代码兼容性,从2.0升级到3.0很多api有了重大变化了,从2.0升级到3.0指南

  # dio: ^2.1.12
  dio: ^3.0.10

参考链接

相关文章
|
PHP
Fatal error: Can't use method return value in write context in
说明:   php环境测试会报错下面错误:Fatal error: Can't use method return value in write context in    解决方案:   首先检查自己的php版本,支付宝sdk和demo测试需要php5.5以上版本。
953 12
|
3月前
|
缓存 Dart 开发工具
解决Flutter报错The method ‘File.create‘ has fewer named arguments than those of overridden method
解决Flutter报错The method ‘File.create‘ has fewer named arguments than those of overridden method
60 3
|
3月前
|
Docker 容器
成功解决:Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but
这篇文章讨论了在使用Docker启动Elasticsearch容器时遇到的一个具体问题:由于配置文件`elasticsearch.yml`解析出错导致容器启动失败。文章提供了详细的排查过程,包括查看容器的日志信息、检查并修正配置文件中的错误(特别是空格问题),并最终成功重新启动了容器。
|
6月前
Could not find method debug()
Could not find method debug()
252 59
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
Error: Element type is invalid: expected a string (for built-in components) or a class/function
2550 0
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
|
SQL Java 数据库连接
attempted to return null from a method with a primitive return type
attempted to return null from a method with a primitive return type
187 0
|
Java 关系型数据库 MySQL
15. 成功解决:java: Can't generate mapping method with primitive return type.
今天启动 SpringBoot 项目时,报了如下错误:`java: Can't generate mapping method with primitive return type.`
1016 0
|
Java Android开发
The method call() of type XXX must override a superclass
The method call() of type XXX must override a superclass
106 0
|
开发工具 Android开发
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
210 0
解决Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.