From aba917ade1f1a2f104977dce429d0e358e26c621 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 22 Mar 2021 17:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A9=BA=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .fvm/fvm_config.json | 3 ++ .gitignore | 1 + .vscode/settings.json | 3 ++ example/lib/main.dart | 6 +-- example/pubspec.lock | 44 ++++++++++----------- example/pubspec.yaml | 2 +- lib/src/builders/dio_error_builder.dart | 14 +++---- lib/src/builders/dio_responses_builder.dart | 2 +- lib/src/parser/dio_parser/dio_parser.dart | 2 +- lib/src/view/dio_error_view.dart | 6 +-- lib/src/view/dio_response_view.dart | 4 +- pubspec.lock | 44 ++++++++++----------- 12 files changed, 69 insertions(+), 62 deletions(-) create mode 100644 .fvm/fvm_config.json create mode 100644 .vscode/settings.json diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json new file mode 100644 index 0000000..309af34 --- /dev/null +++ b/.fvm/fvm_config.json @@ -0,0 +1,3 @@ +{ + "flutterSdkVersion": "2.0.0" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1985397..b76ade6 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ build/ !**/ios/**/default.mode2v3 !**/ios/**/default.pbxuser !**/ios/**/default.perspectivev3 +flutter_sdk diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c6471a7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dart.flutterSdkPath": "/Users/akufe/fvm/versions/2.0.0" +} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 6dcf050..ab72cf0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -57,14 +57,14 @@ class NetTool { static Dio dio = Dio(); static init() { dio.interceptors.add(InterceptorsWrapper( - onRequest: (options) async { + onRequest: (options, handler) async { return options; }, - onResponse: (response) async { + onResponse: (response, handler) async { LoggerData.addData(response); return response; }, - onError: (DioError e) async { + onError: (DioError e, handler) async { LoggerData.addData(e); return e; }, diff --git a/example/pubspec.lock b/example/pubspec.lock index 3940350..492d6e6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" auto_size_text: dependency: transitive description: @@ -21,35 +21,35 @@ packages: name: boolean_selector url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.flutter-io.cn" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -77,14 +77,14 @@ packages: name: dio url: "https://pub.flutter-io.cn" source: hosted - version: "3.0.10" + version: "4.0.0-prev3" fake_async: dependency: transitive description: name: fake_async url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -122,21 +122,21 @@ packages: name: http_parser url: "https://pub.flutter-io.cn" source: hosted - version: "3.1.4" + version: "4.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" package_info: dependency: transitive description: @@ -150,7 +150,7 @@ packages: name: path url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" plugin_platform_interface: dependency: transitive description: @@ -183,56 +183,56 @@ packages: name: source_span url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.flutter-io.cn" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0 <2.11.0" - flutter: ">=1.17.0 <2.0.0" + dart: ">=2.12.0-29.10.beta <3.0.0" + flutter: ">=1.17.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 8e9762a..99dad96 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.0 - dio: ^3.0.10 + dio: ^4.0.0-prev3 power_logger: path: ../ get: diff --git a/lib/src/builders/dio_error_builder.dart b/lib/src/builders/dio_error_builder.dart index fb261e7..31aac61 100644 --- a/lib/src/builders/dio_error_builder.dart +++ b/lib/src/builders/dio_error_builder.dart @@ -12,26 +12,26 @@ class DioErrorBuilder extends StatefulWidget { } class _DioErrorBuilderState extends State { - RequestOptions get _request => widget?.data?.request; + RequestOptions get _request => widget?.data?.requestOptions; String renderErrText(DioErrorType type) { switch (type) { - case DioErrorType.CONNECT_TIMEOUT: + case DioErrorType.connectTimeout: return '连接超时'; break; - case DioErrorType.SEND_TIMEOUT: + case DioErrorType.sendTimeout: return '发送超时'; break; - case DioErrorType.RECEIVE_TIMEOUT: + case DioErrorType.receiveTimeout: return '接收超时'; break; - case DioErrorType.RESPONSE: + case DioErrorType.response: return 'Serve Side Error'; break; - case DioErrorType.CANCEL: + case DioErrorType.cancel: return '取消连接'; break; - case DioErrorType.DEFAULT: + case DioErrorType.other: return '未知错误'; break; } diff --git a/lib/src/builders/dio_responses_builder.dart b/lib/src/builders/dio_responses_builder.dart index 221196f..26cc94e 100644 --- a/lib/src/builders/dio_responses_builder.dart +++ b/lib/src/builders/dio_responses_builder.dart @@ -12,7 +12,7 @@ class DioResponseBuilder extends StatefulWidget { } class _DioResponseBuilderState extends State { - RequestOptions get _request => widget?.data?.request; + RequestOptions get _request => widget?.data?.requestOptions; @override Widget build(BuildContext context) { diff --git a/lib/src/parser/dio_parser/dio_parser.dart b/lib/src/parser/dio_parser/dio_parser.dart index 9e7b805..6739c03 100644 --- a/lib/src/parser/dio_parser/dio_parser.dart +++ b/lib/src/parser/dio_parser/dio_parser.dart @@ -21,7 +21,7 @@ class DioParser { } /// get dio request - RequestOptions get request => _response.request; + RequestOptions get request => _response.requestOptions; /// get dio response Response get response => _response; diff --git a/lib/src/view/dio_error_view.dart b/lib/src/view/dio_error_view.dart index d27b7a7..db8e520 100644 --- a/lib/src/view/dio_error_view.dart +++ b/lib/src/view/dio_error_view.dart @@ -13,7 +13,7 @@ class DioErrorView extends StatefulWidget { } class _DioErrorViewState extends State { - RequestOptions get _request => widget.data.request; + RequestOptions get _request => widget.data.requestOptions; _buildBaseURL() { return _request.baseUrl == null || _request.baseUrl.length == 0 ? const SizedBox() @@ -61,10 +61,10 @@ class _DioErrorViewState extends State { return Scaffold( appBar: AppBar( backgroundColor: Colors.red[600], - title: Text(widget.data.request.path), + title: Text(widget.data.requestOptions.path), actions: [ Chip( - label: Text(widget.data.request.method), + label: Text(widget.data.requestOptions.method), backgroundColor: Colors.lightGreen, ), SizedBox(width: 8), diff --git a/lib/src/view/dio_response_view.dart b/lib/src/view/dio_response_view.dart index a0f8e82..7bedae1 100644 --- a/lib/src/view/dio_response_view.dart +++ b/lib/src/view/dio_response_view.dart @@ -152,10 +152,10 @@ class _DioResponseViewState extends State { return Scaffold( appBar: AppBar( backgroundColor: Colors.green[600], - title: Text(widget.data.request.path), + title: Text(widget.data.requestOptions.path), actions: [ Chip( - label: Text(widget.data.request.method), + label: Text(widget.data.requestOptions.method), backgroundColor: Colors.lightGreen, ), SizedBox(width: 8), diff --git a/pubspec.lock b/pubspec.lock index 8bef622..788340a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" auto_size_text: dependency: "direct main" description: @@ -21,35 +21,35 @@ packages: name: boolean_selector url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.flutter-io.cn" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" device_info: dependency: "direct main" description: @@ -70,14 +70,14 @@ packages: name: dio url: "https://pub.flutter-io.cn" source: hosted - version: "3.0.10" + version: "4.0.0-prev3" fake_async: dependency: transitive description: name: fake_async url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -108,21 +108,21 @@ packages: name: http_parser url: "https://pub.flutter-io.cn" source: hosted - version: "3.1.4" + version: "4.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" package_info: dependency: "direct main" description: @@ -136,7 +136,7 @@ packages: name: path url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" plugin_platform_interface: dependency: transitive description: @@ -162,56 +162,56 @@ packages: name: source_span url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.flutter-io.cn" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.17.0 <2.0.0" + dart: ">=2.12.0-29.10.beta <3.0.0" + flutter: ">=1.17.0"