flutter版本升级到1.17.5版本后报错

2020-07-24  本文已影响0人  骑马纵天下
Compiler message:
../../Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/dio-2.1.4/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:694:8: Context: This is the overridden method ('add').
  void add(String name, Object value,
       ^
../../Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/dio-2.1.4/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:703:8: Context: This is the overridden method ('set').
  void set(String name, Object value,
       ^                                                                                                                                                                                                            
dio: ^3.0.9
Compiler message:                                  
lib/common/dao/order_dao.dart:743:19: Error: Method not found: 'UploadFileInfo'.
      "file": new UploadFileInfo(new File(path), name),                 
                  ^^^^^^^^^^^^^^                                        
lib/common/dao/order_dao.dart:747:30: Error: Method not found: 'FormData.from'.
      'params': new FormData.from(paramData),                           
                             ^^^^                                       lib/common/net/interceptors/header_interceptor.dart:15:12: Error: A value of type 'RequestOptions' can't be assigned to a variable of type 'Future<dynamic>'.
 - 'RequestOptions' is from 'package:dio/src/options.dart' ('../../Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/dio-3.0.9/lib/src/options.dart').
 - 'Future' is from 'dart:async'.                                       
    return options;                                                     
           ^                                                                                                                    lib/common/net/interceptors/log_interceptor.dart:28:12: Error: A value of type 'Response<dynamic>' can't be assigned to a variable of type 'Future<dynamic>'.
 - 'Response' is from 'package:dio/src/response.dart' ('../../Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/dio-3.0.9/lib/src/response.dart').
 - 'Future' is from 'dart:async'.                                       
    return response; // continue                                        
           ^                                                            lib/common/net/interceptors/log_interceptor.dart:37:12: Error: A value of type 'DioError' can't be assigned to a variable of type 'Future<dynamic>'.
 - 'DioError' is from 'package:dio/src/dio_error.dart' ('../../Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/dio-3.0.9/lib/src/dio_error.dart').
 - 'Future' is from 'dart:async'.                                       
    return err;                                                         
           ^                                                            lib/common/net/interceptors/response_interceptor.dart:15:60: Error: The getter 'primaryType' isn't defined for the class 'String'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'primaryType'.
      if (option.contentType != null && option.contentType.primaryType == "text") {
                                                           ^^^^^^^^^^^                                                     lib/common/net/interceptors/response_interceptor.dart:23:18: Error: A value of type 'ResultData' can't be assigned to a variable of type 'Future<dynamic>'.
 - 'ResultData' is from 'package:nurse_coming_app/common/net/result_data.dart' ('lib/common/net/result_data.dart').
 - 'Future' is from 'dart:async'.                                       
      return new ResultData(response.data, false, response.statusCode, headers: response.headers);

修改内容

FormData.from修改为FormData.fromMap
UploadFileInfo(File(path), name,)修改为MultipartFile.fromFile(path, filename: name)
option.contentType.primaryType修改为option.contentType
options.contentType = ContentType.json;修改为options.contentType = Headers.jsonContentType;
@override
  onRequest(RequestOptions options) async{
    ///超时
    options.connectTimeout = 15000;

    return options;
  }
上一篇下一篇

猜你喜欢

热点阅读