Commit 478f2c8c37488a0ac0b12b118da284b1646e9e56
1 parent
a2092915
feat:更新插件
Showing
2 changed files
with
9 additions
and
1 deletions
lib/network/network_manager.dart
| 1 | import 'dart:io'; | 1 | import 'dart:io'; |
| 2 | 2 | ||
| 3 | import 'package:dio/dio.dart'; | 3 | import 'package:dio/dio.dart'; |
| 4 | +import 'package:flutter/foundation.dart'; | ||
| 5 | +import 'package:flutter_easyloading/flutter_easyloading.dart'; | ||
| 4 | 6 | ||
| 5 | enum HttpMethod { | 7 | enum HttpMethod { |
| 6 | get, | 8 | get, |
| @@ -53,7 +55,11 @@ class DioUtil { | @@ -53,7 +55,11 @@ class DioUtil { | ||
| 53 | } else { | 55 | } else { |
| 54 | errorCallBack('请求失败'); | 56 | errorCallBack('请求失败'); |
| 55 | } | 57 | } |
| 56 | - } on Error { | 58 | + } on DioError catch(error) { |
| 59 | + EasyLoading.dismiss(); | ||
| 60 | + if (kDebugMode) { | ||
| 61 | + print(error); | ||
| 62 | + } | ||
| 57 | rethrow; | 63 | rethrow; |
| 58 | } | 64 | } |
| 59 | } | 65 | } |
pubspec.yaml
| @@ -79,6 +79,8 @@ dependencies: | @@ -79,6 +79,8 @@ dependencies: | ||
| 79 | device_info_plus: ^9.0.1 | 79 | device_info_plus: ^9.0.1 |
| 80 | # 用户权限申请 https://pub.dev/packages/permission_handler | 80 | # 用户权限申请 https://pub.dev/packages/permission_handler |
| 81 | permission_handler: ^10.2.0 | 81 | permission_handler: ^10.2.0 |
| 82 | + # 网络状态监听 https://pub.dev/packages/connectivity_plus | ||
| 83 | + connectivity_plus: ^4.0.1 | ||
| 82 | 84 | ||
| 83 | dev_dependencies: | 85 | dev_dependencies: |
| 84 | build_runner: ^2.4.4 | 86 | build_runner: ^2.4.4 |