├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib └── net │ ├── base │ ├── abstract_dio_manager.dart │ └── dio_manager.dart │ ├── constant │ └── net_const.dart │ ├── error │ └── net_exception.dart │ ├── flutter_net.dart │ └── json │ └── json_decoder.dart ├── pubspec.lock ├── pubspec.yaml └── sample ├── .gitignore ├── .metadata ├── README.md ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── hikvision │ │ │ │ └── net_sample │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── bean │ ├── bean.dart │ └── page.dart ├── json │ └── mapper.dart ├── main.dart └── manager │ └── net_manager.dart ├── pubspec.lock └── pubspec.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Flutter.podspec 62 | **/ios/Flutter/Generated.xcconfig 63 | **/ios/Flutter/app.flx 64 | **/ios/Flutter/app.zip 65 | **/ios/Flutter/flutter_assets/ 66 | **/ios/Flutter/flutter_export_environment.sh 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 76 | sample/pubspec.lock 77 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 8af6b2f038c1172e61d418869363a28dffec3cb4 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.0.1] - TODO: Add release date. 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 使用方式: 2 | 3 | ``` 4 | 添加如下项目的 pubspec.yaml 文件的dependencies中 5 | 6 | flutter_net: 7 | git: 8 | url: https://github.com/Jimmuy/flutter_net.git 9 | 10 | ``` 11 | # 摘要: 12 | 13 | Flutter项目中的网络请求采用的是dio网络请求库,dio是一个强大的Dart Http请求库,支持Restful API、FormData、拦截器、请求取消、Cookie管理、文件上传/下载、超时、自定义适配器等... 14 | 15 | 关于dio的使用本文档不多作介绍,感兴趣可以 [到这里](https://github.com/flutterchina/dio/blob/master/README-ZH.md)查阅具体的使用 16 | 17 | 由于看到的封装方式都是基于回调的形式,那么再多个网络组合操作时不得不再用RxDart进行封装,而返回future形式很大程度上解决了这些问题。 18 | 19 | 本文档主要说明对dio使用的上层封装,简化了dio的使用,方便上层开发进行网络通信。 20 | 21 | ## 类文件说明: 22 | 23 | ``` 24 | /** 25 | * 网络请求管理实现类,可根据项目需求进行自定义参数配置 26 | */ 27 | class DioManager extends AbstractDioManager{} 28 | ``` 29 | 30 | 31 | ``` 32 | /** 33 | * 网络请求管理类抽象层 34 | * 负责执行网络请求的通用逻辑 35 | * 不同项目的不同配置交给上层实现 36 | */ 37 | abstract class AbstractDioManager {} 38 | ``` 39 | 40 | 41 | ``` 42 | /** 43 | *常量类,定义了通用的网络请求错误以及常用的请求方式枚举(GET/POST/PUT/DELETE),以及HTTP层的错误码 44 | */ 45 | class HttpCode {} 46 | ``` 47 | 48 | ``` 49 | /** 50 | * 网络异常类 51 | */ 52 | class NetWorkException implements Exception {} 53 | ``` 54 | 55 | ``` 56 | /** 57 | 58 | * json解析相关类 json_decoder.dart,负责json实例化 59 | 60 | */ 61 | ``` 62 | 63 | ``` 64 | net_manager 65 | /** 66 | * 简化网络请求而封装的顶层函数,提供常用的几种请求 67 | */ 68 | Future get(String url, {params, options, cancelToken}) => 69 | DioManager.getInstance().get(url, params: params, options: options, token: cancelToken); 70 | Future post(String url, {params, options, cancelToken}) => 71 | DioManager.getInstance().post(url, params: params, options: options, token: cancelToken); 72 | Future delete(String url, {params, options, cancelToken}) => 73 | DioManager.getInstance().delete(url, params: params, options: options, token: cancelToken); 74 | Future put(String url, {params, options, cancelToken}) => 75 | DioManager.getInstance().put(url, params: params, options: options, token: cancelToken); 76 | 77 | ///当网络请求返回格式为{"code":0,"msg":"OK","data":[]}形式的时候,使用requestList请求数据 78 | 79 | Future> requestList (String url , {Method method: Method. GET, params , options , token , }) 80 | 81 | ///当网络请求返回格式为分页形式的时候,使用requestList请求数据,,分页的数据结构为PageObj仅供参考 82 | 83 | Future> requestPage (String url , Method method:Method. GET , params , options , token}) 84 | 85 | ``` 86 | 详情使用方式参见sample项目说明,请求库中默认提供了针对Json数据的的解析,sample中同样提供了推荐的json实例化方式,推荐使用 87 | 88 | [json对象生成工具](https://javiercbk.github.io/json_to_dart/)工具来进行数据对象Model的生成。 89 | 90 | 91 | ## 使用: 92 | 93 | 通常情况下服务器返回的格式为code,message,data这种json形式,DioManager在初始化的时候也添加了对应的通用头,和业务错误码映射以及json解析方式等根据项目定制的功能,如果需要自定义请自行继承AbstractDioManager实现抽象方法来适配服务器的返回。在项目中默认默认实现好的为DioManger. 94 | 95 | 若需要自定义,通常需要实现如下方法 96 | 97 | ``` 98 | ///具体的解析逻辑上层实现 diomanager 默认返回jsonstring 若需要实例化成实体请使用json序列化库进行实例化 99 | T decode(Response response); 100 | ///业务逻辑报错映射 101 | NetWorkException getBusinessErrorResult(int code, String error); 102 | /// HTTP层网络请求错误翻译 103 | NetWorkException getHttpErrorResult(DioError e); 104 | ///初始化dio参数,统一配置参数 105 | BaseOptions configBaseOptions(); 106 | ///判断业务层的返回成功还是失败,失败后报错,成功后进行数据解析 107 | bool isSuccess(Response response); 108 | ///默认是“code”获取response code 若服务器请求返回的code的key不一样,请重写此方法 109 | int getCode(Response response) { 110 | return response.data["code"]; 111 | } 112 | ///默认是“message”获取response message 若服务器请求返回的message的key不一样,请重写此方法 113 | String getMessage(Response response) { 114 | return response.data["message"]; 115 | } 116 | ///dio的配置工作,进行添加拦截器等操作 117 | void configDio(); 118 | ``` 119 | 120 | 121 | 通常情况下使用DioManager默认实现即可,以get请求为例,如下: 122 | 123 | ``` 124 | 125 | /** 126 | * @Model->数据实体,若想返回json string则可以直接将泛型定义为String 127 | * @URL->请求的url 128 | * @param->请求参数,可不填,不填为null,参数类型Map。 129 | * @data->返回数据,填写泛型则返回实例化的对象 130 | * @error->通常情况下返回包装好的 NetWorkException 对象,可以从对象中获取code和msg 131 | */ 132 | get(URL, params: map).then((data){ 133 | //使用网络请求返回值进行业务代码编写 134 | }).catchError((error) { 135 | //网络请求异常 136 | }.whenComplete((){ 137 | //网络请求结束,类似于finally 138 | }); 139 | //post delete put 请求的使用同理。 140 | ``` 141 | ## 使用进阶: 142 | 143 | 调用顶层函数get/post/put/delete(为了方便,以下均采用post方式请求作为说明)返回值均为Future对象,所以使用Future可以组合出很多种请求方式。 144 | 145 | e.g:A,B,C三个请求,A->B->C,即为A执行完之后执行B,B执行完之后执行C,C执行完这时网络请求流程结束。 146 | 147 | ``` 148 | Future(() { 149 | return get(URL_A); 150 | }) 151 | .then((data) { 152 | //根据第一个请求的返回值请求下一个请求 153 | return get(URL_B,data.param); 154 | }) 155 | .then((data) { 156 | //这里处理第二次请求的结果 157 | return get(URL_C,data.param); 158 | }) 159 | .then((data) { 160 | //这里处理第三次次请求的结果 161 | }) 162 | .catchError((error) { 163 | // 这里处理请求异常的情况,包括http层code!=200的情况以及业务层code!=0的情况,这种写法可以在第一个网络请求失败后直接结束剩下的网络请求,也可以针对每次请求单独的获取异常的情况,具体的参照Future的使用,因为每个网络请求返回的类型都是Future类型,所以可以根据业务的不同定制流程。 164 | ``` 165 | }) 166 | 167 | e.g:A,B,C三个网络请求,C请求要等待A,B请求返回后进行请求。 168 | 169 | ``` 170 | Future.wait([ 171 | get(URL.A), 172 | get(URL.B) 173 | ]).then((data) { 174 | return get(URL.C); 175 | }).then((data) { 176 | }).catchError((error) { 177 | }); 178 | ``` 179 | 同样的,dart1.9后提供了await和aysnc的方式进行异步同步操作,aysnc的返回值依然是一个Future,可根据自己的喜好去处理组合的网络请求. 180 | ### 处理网络请求错误: 181 | 182 | 当单个网络请求时,可以使用catchError来获取服务器定义的请求失败的信息。 183 | 184 | 例如: 185 | 186 | ``` 187 | get(URL.C).then((data) { 188 | //success 189 | }).catchError((error) { 190 | if (error is NetWorkException){ 191 | //根据error.code 和 error.message 处理请求错误逻辑 192 | } 193 | ``` 194 | }); 195 | 当多个网络请求组合的时候,需要根据业务需求去判断是否需要针对每个网络请求返回的Future进行单独的catchError,值得注意的是,catchError的返回值依然是个future对象,若A->B->C的串行请求在A处进行了catchError操作而不在闭包里threw error或者return Future.error的话,这个串行请求就会继续下去,如果在最后进行catchError那么在A处发生失败时,剩下的请求就不会进行下去了. 196 | 197 | ``` 198 | //第一种情况 199 | Future(() { 200 | return get(URL_A); 201 | }) 202 | .then((data) { 203 | //根据第一个请求的返回值请求下一个请求 204 | return get(URL_B,data.param); 205 | }) 206 | .then((data) { 207 | //这里处理第二次请求的结果 208 | return get(URL_C,data.param); 209 | }) 210 | .then((data) { 211 | //这里处理第三次次请求的结果 212 | }) 213 | .catchError((error) { 214 | //这种情况,当A出错,后面的B和C都不会执行,error是A的error response 215 | }) 216 | //第二种情况 217 | Future(() { 218 | return get(URL_A); 219 | }).then((data) { 220 | //根据第一个请求的返回值请求下一个请求 221 | return get(URL_B,data.param); 222 | }) .catchError((error) { 223 | //这种情况,当A出错,后面的B和C依然会执行若想终端剩下的操作,则需要threw error 或者 return Future.error 224 | }) 225 | .then((data) { 226 | //这里处理第二次请求的结果 227 | return get(URL_C,data.param); 228 | }) 229 | .then((data) { 230 | //这里处理第三次次请求的结果 231 | }) 232 | ``` 233 | ### 终止网络请求: 234 | 235 | ``` 236 | CancelToken token = CancelToken(); 237 | dio.get(url, cancelToken: token) 238 | .catchError((DioError err){ 239 | if (CancelToken.isCancel(err)) { 240 | print('Request canceled! '+ err.message) 241 | }else{ 242 | // handle error. 243 | } 244 | }); 245 | // cancel the requests with "cancelled" message. 246 | token.cancel("cancelled"); 247 | ``` 248 | 注意: 同一个cancel token 可以用于多个请求,当一个cancel token取消时,所有使用该cancel token的请求都会被取消。CancelToken的内部实现是使用了Completer 249 | 关于Completer的使用大概是下面这样。 250 | 251 | ``` 252 | // 实例化一个Completer 253 | var completer = Completer(); 254 | // 这里可以拿到这个completer内部的Future 255 | var future = completer.future; 256 | // 需要的话串上回调函数。 257 | future.then((value)=> print('$value')); 258 | //做些其它事情 259 | ... 260 | // 设置为完成状态 261 | completer.complete("done"); 262 | ``` 263 | 上述代码片段中,当你创建了一个Completer以后,其内部会包含一个Future。你可以在这个Future上通过then, catchError和whenComplete串上你需要的回调。拿着这个Completer实例,在你的代码里的合适位置,通过调用complete函数即可完成这个Completer对应的Future。控制权完全在你自己的代码手里。当然你也可以通过调用completeError来以异常的方式结束这个Future。 264 | 除了dio提供的cancel方式之外,Steam流也可以实现类似的效果: 265 | 266 | ``` 267 | var asStream = get(URL).asStream(); 268 | var listen = asStream.listen((data){ 269 | //处理逻辑 270 | }); 271 | listen.cancel(); 272 | ``` 273 | 通过listene去监听数据流然后通过cancel方法可以取消监听,如果需要取消网络请求,还是推荐使用封装好的cancelToken。 274 | -------------------------------------------------------------------------------- /lib/net/base/abstract_dio_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import '../constant/net_const.dart'; 4 | import '../error/net_exception.dart'; 5 | 6 | /// 网络请求管理类抽象层\ 7 | /// 负责执行网络请求的通用逻辑 8 | /// 不同项目的不同配置交给上层实现 9 | 10 | abstract class AbstractDioManager { 11 | late Dio dio; 12 | 13 | AbstractDioManager() { 14 | dio = new Dio(configBaseOptions()); 15 | configDio(); 16 | } 17 | 18 | ///get请求 19 | Future get(String url, {Map? params, Options? options, token}) async { 20 | return requestHttp( 21 | url, 22 | Method.GET, 23 | params: params, 24 | options: options, 25 | cancelToken: token, 26 | decode: this.decode, 27 | ); 28 | } 29 | 30 | ///post请求 31 | Future post(String url, {Map? params, Options? options, token}) async { 32 | return requestHttp( 33 | url, 34 | Method.POST, 35 | params: params, 36 | options: options, 37 | cancelToken: token, 38 | decode: this.decode, 39 | ); 40 | } 41 | 42 | Future delete(String url, {Map? params, Options? options, token}) async { 43 | return requestHttp( 44 | url, 45 | Method.DELETE, 46 | params: params, 47 | options: options, 48 | cancelToken: token, 49 | decode: this.decode, 50 | ); 51 | } 52 | 53 | Future put(String url, {Map? params, Options? options, token}) async { 54 | return requestHttp( 55 | url, 56 | Method.PUT, 57 | params: params, 58 | options: options, 59 | cancelToken: token, 60 | decode: this.decode, 61 | ); 62 | } 63 | 64 | Future patch(String url, {Map? params, Options? options, token}) async { 65 | return requestHttp( 66 | url, 67 | Method.PATCH, 68 | params: params, 69 | options: options, 70 | cancelToken: token, 71 | decode: this.decode, 72 | ); 73 | } 74 | 75 | Future requestHttp(String url, 76 | Method method, { 77 | Map? params, 78 | Map? headers, 79 | String mediaType = 'application/json; charset=utf-8', 80 | options, 81 | cancelToken, 82 | required R? decode(dynamic json), 83 | }) { 84 | final methodName = method.toString().split('.')[1]; 85 | if (method == Method.GET) { 86 | return request( 87 | url, 88 | methodName, 89 | params: params, 90 | headers: headers, 91 | mediaType: mediaType, 92 | cancelToken: cancelToken, 93 | options: options, 94 | decode: decode, 95 | ); 96 | } 97 | return request( 98 | url, 99 | methodName, 100 | body: params, 101 | headers: headers, 102 | mediaType: mediaType, 103 | cancelToken: cancelToken, 104 | options: options, 105 | decode: decode, 106 | ); 107 | } 108 | 109 | ///R是返回类型,T是数据类型 110 | Future request(String url, 111 | String method, { 112 | Map? params, 113 | Map? body, 114 | Map? headers, 115 | String mediaType = 'application/json; charset=utf-8', 116 | Options? options, 117 | cancelToken, 118 | required R? decode(dynamic json), 119 | }) async { 120 | Response response; 121 | 122 | 123 | final opt = options ?? Options(); 124 | try { 125 | response = await dio.request( 126 | url, 127 | data: body, 128 | options: opt.copyWith( 129 | headers: headers, 130 | method: method.toUpperCase(), 131 | responseType: ResponseType.json, 132 | contentType: mediaType, 133 | ), 134 | queryParameters: params, 135 | ); 136 | } on DioError catch (error) { 137 | if (isShowLog()) printParams(params ?? body ?? {}, url, headers, null); 138 | print("---------- net error $error"); 139 | throw getHttpErrorResult(error); 140 | } 141 | 142 | ///打印日志 143 | if (isShowLog()) printParams(params ?? body ?? {}, url, headers, response); 144 | dynamic data; 145 | //优先解析请求是否出错 146 | if (!isSuccess(response)) { 147 | handleFailed(response, data, decode); 148 | } else { 149 | //确保请求成功的情况下,再实例化数据 150 | data = handleSuccess(data, decode, response); 151 | } 152 | return data; 153 | } 154 | 155 | R handleSuccess(data, decode(dynamic json), Response response) { 156 | //确保请求成功的情况下,再实例化数据 157 | try { 158 | data = decode(response.data['data']); 159 | return data as R; 160 | } catch (e) { 161 | throw getBusinessErrorResult(HttpCode.PARSE_JSON_ERROR, "json parse error 0 ~ $e", null); 162 | } 163 | } 164 | 165 | handleFailed(Response response, data, decode(dynamic json)) { 166 | if (response.data is Map && response.data["data"] != null) { 167 | try { 168 | data = decode(response.data['data']); 169 | } catch (e) { 170 | ///解析数据出错 171 | throw getBusinessErrorResult(HttpCode.PARSE_JSON_ERROR, "json parse error 1 ~ $e", null); 172 | } 173 | 174 | ///抛出含有数据的error 175 | throw getBusinessErrorResult(getCode(response), getMessage(response), data); 176 | } else { 177 | ///抛出没有数据的error 178 | throw getBusinessErrorResult(getCode(response), getMessage(response), null); 179 | } 180 | } 181 | 182 | void printParams(Map params, url, headers, response) { 183 | print("------ url:$url"); 184 | print("------ headers:$headers"); 185 | 186 | final pms = params.toString(); 187 | final len = pms.length; 188 | final res = response == null ? "" : response.data?.toString() ?? ""; 189 | try { 190 | if (len > 100) { 191 | int startIndex = 0; 192 | int endIndex = 100; 193 | while (true) { 194 | print("---------- params: ${pms.substring(startIndex, endIndex)}"); 195 | if (endIndex == pms.length) { 196 | break; 197 | } 198 | startIndex = endIndex; 199 | endIndex += 100; 200 | if (endIndex > pms.length) { 201 | endIndex = pms.length; 202 | } 203 | } 204 | } else { 205 | print("---------- params: $pms"); 206 | } 207 | } catch (e) { 208 | print("---------- printLog()打印参数异常----"); 209 | } 210 | try { 211 | int length = 1500; 212 | final len = res.length; 213 | if (len > length) { 214 | int startIndex = 0; 215 | int endIndex = length; 216 | while (true) { 217 | print("------------response: ${res.substring(startIndex, endIndex)}"); 218 | if (endIndex == res.length) { 219 | break; 220 | } 221 | startIndex = endIndex; 222 | endIndex += length; 223 | if (endIndex > res.length) { 224 | endIndex = res.length; 225 | } 226 | } 227 | } else { 228 | print("------------response: $res"); 229 | } 230 | } catch (e) { 231 | print("---------- printLog()打印response异常----"); 232 | } 233 | } 234 | 235 | ///具体的解析逻辑上层实现 236 | T? decode(dynamic response); 237 | 238 | ///业务逻辑报错映射 239 | NetWorkException getBusinessErrorResult(int code, String error, T data); 240 | 241 | /// HTTP层网络请求错误翻译 242 | NetWorkException getHttpErrorResult(DioError e); 243 | 244 | ///初始化dio参数 245 | BaseOptions configBaseOptions(); 246 | 247 | ///判断业务层的返回成功还是失败,失败后报错,成功后进行数据解析 248 | bool isSuccess(Response response); 249 | 250 | ///默认是“code”获取response code 若服务器请求返回的code的key不一样,请重写此方法 251 | int getCode(Response response) { 252 | return response.data["code"]; 253 | } 254 | 255 | ///是否显示log日志 256 | bool isShowLog() => false; 257 | 258 | ///默认是“message”获取response message 若服务器请求返回的message的key不一样,请重写此方法 259 | String getMessage(Response response) { 260 | return response.data["message"]; 261 | } 262 | 263 | ///dio的配置工作,进行添加拦截器等操作 264 | void configDio(); 265 | } 266 | -------------------------------------------------------------------------------- /lib/net/base/dio_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import '../constant/net_const.dart'; 4 | import '../error/net_exception.dart'; 5 | import 'abstract_dio_manager.dart'; 6 | 7 | /// dio网络请求管理类,实现了大部分通用逻辑,需要按照项目需求自定义的部分请在子类中实现,子类应是单例 8 | 9 | abstract class DioManager extends AbstractDioManager { 10 | ///统一配置,用于添加统一头,单度添加请求配置请在请求中填写,单次的配置只影响单次的请求,并不影响统一配置 11 | @override 12 | BaseOptions configBaseOptions() { 13 | return BaseOptions( 14 | connectTimeout: HttpCode.TIME_OUT, receiveTimeout: HttpCode.TIME_OUT, baseUrl: getBaseUrl(), responseType: ResponseType.json); 15 | } 16 | 17 | @override 18 | void configDio() { 19 | dio.interceptors.add(LogInterceptor(requestBody: isShowLog(), responseBody: isShowLog())); //是否开启请求日志 20 | } 21 | 22 | ///业务逻辑报错映射,目前暂时不做翻译工作,默认返回服务端返回的报错信息 23 | @override 24 | NetWorkException getBusinessErrorResult(int code, String error, T data) => NetWorkException(code, error, data: data); 25 | 26 | /// HTTP层网络请求错误翻译 27 | @override 28 | NetWorkException getHttpErrorResult(DioError e) { 29 | String? statusMessage; 30 | int? statusCode; 31 | if (e.response != null) { 32 | statusCode = e.response?.statusCode; 33 | statusMessage = e.response?.statusMessage; 34 | } 35 | if (e.type == DioErrorType.connectTimeout) { 36 | statusMessage = "连接超时"; 37 | statusCode = HttpCode.CONNECT_TIMEOUT; 38 | } else if (e.type == DioErrorType.sendTimeout) { 39 | statusMessage = "请求超时"; 40 | statusCode = HttpCode.SEND_TIMEOUT; 41 | } else if (e.type == DioErrorType.receiveTimeout) { 42 | statusMessage = "响应超时"; 43 | statusCode = HttpCode.RECEIVE_TIMEOUT; 44 | } else if (e.type == DioErrorType.cancel) { 45 | statusMessage = "请求取消"; 46 | statusCode = HttpCode.REQUEST_CANCEL; 47 | } else if (e.type == DioErrorType.response) { 48 | check(e.response); 49 | switch (e.response?.statusCode) { 50 | case 400: 51 | statusMessage = "请求语法错误"; 52 | break; 53 | case 401: 54 | //退出登录 55 | logout(); 56 | statusMessage = "鉴权失败"; 57 | break; 58 | case 403: 59 | statusMessage = "服务器拒绝执行"; 60 | break; 61 | case 404: 62 | statusMessage = "无法连接服务器"; 63 | break; 64 | case 405: 65 | statusMessage = "请求方法被禁止"; 66 | break; 67 | case 500: 68 | statusMessage = "服务器内部错误"; 69 | break; 70 | case 502: 71 | statusMessage = "无效的请求"; 72 | break; 73 | case 503: 74 | statusMessage = "服务器挂了"; 75 | break; 76 | case 505: 77 | statusMessage = "不支持HTTP协议请求"; 78 | break; 79 | default: 80 | statusMessage = "未知错误"; 81 | break; 82 | } 83 | } else { 84 | statusMessage = "未知错误"; 85 | statusCode = HttpCode.UNKNOWN_NET_ERROR; 86 | } 87 | return new NetWorkException(statusCode, statusMessage, data: e); 88 | } 89 | 90 | ///判断网络请求是否成功 91 | @override 92 | bool isSuccess(Response response) => response.data["code"] == HttpCode.SUCCESS && response.data["success"]; 93 | 94 | ///设置baseURl 95 | String getBaseUrl(); 96 | 97 | ///token失效登出逻辑 98 | void logout(); 99 | 100 | bool needCheck403() => false; 101 | 102 | /// * 为了不影响以前业务以及别的业务线 103 | /// * 网关端在响应头里新增字段 X-Status-Code 来区分是真的401还是403,此时 response?.statusCode 返回的仍是401 104 | /// * 是403时 body会返回没有权限的 权限码和名字json(目前已跟产品确认不需要toast提示) 105 | /// * 包含此字段时才去判断 不包含则继续维持之前逻辑 ,如果是真的403 则将response?.statusCode赋值为403 106 | /// 107 | void check(Response? response) { 108 | if (response != null) { 109 | Headers headers = response.headers; 110 | var code; 111 | try { 112 | code = headers.value(Authority.AUTHORITY_ERROR_HEADER_KEY); 113 | } catch (e) { 114 | code = null; 115 | } 116 | if (Authority.AUTHORITY_ERROR_CODE.toString() == code) { 117 | ///如果响应头里 X-Status-Code有值且是403 说明是真的没有权限 此时把code赋值为403, 118 | response.statusCode = Authority.AUTHORITY_ERROR_CODE; 119 | } 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/net/constant/net_const.dart: -------------------------------------------------------------------------------- 1 | class Token { 2 | static String? token; 3 | } 4 | 5 | class Authority { 6 | static const int AUTHORITY_ERROR_CODE = 403; 7 | static const String AUTHORITY_ERROR_HEADER_KEY = "X-Status-Code"; 8 | } 9 | 10 | ///错误编码 11 | class HttpCode { 12 | ///未知网络错误 13 | static const UNKNOWN_NET_ERROR = 10086; 14 | 15 | ///网络错误 16 | static const NETWORK_ERROR = -1001; 17 | 18 | ///网络超时 19 | static const CONNECT_TIMEOUT = -1002; 20 | static const SEND_TIMEOUT = -1003; 21 | static const RECEIVE_TIMEOUT = -1004; 22 | 23 | ///请求取消 24 | static const REQUEST_CANCEL = -1005; 25 | 26 | ///JSON解析异常 27 | static const PARSE_JSON_ERROR = -1006; 28 | 29 | ///成功的code 30 | static const SUCCESS = 0; 31 | 32 | ///超时时长 33 | static const TIME_OUT = 15000; 34 | } 35 | 36 | enum Method { GET, POST, PUT, DELETE, PATCH } 37 | -------------------------------------------------------------------------------- /lib/net/error/net_exception.dart: -------------------------------------------------------------------------------- 1 | /// 网络异常类 2 | 3 | class NetWorkException implements Exception { 4 | int? code; 5 | String? message; 6 | T? data; 7 | 8 | NetWorkException(this.code, this.message, {this.data}); 9 | 10 | @override 11 | String toString() { 12 | return '网络异常{code: $code, message: $message, data: $data}'; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/net/flutter_net.dart: -------------------------------------------------------------------------------- 1 | library flutter_net; 2 | 3 | export 'package:dio/dio.dart'; 4 | 5 | export 'base/abstract_dio_manager.dart'; 6 | export 'base/dio_manager.dart'; 7 | export 'constant/net_const.dart'; 8 | export 'error/net_exception.dart'; 9 | export 'json/json_decoder.dart'; 10 | -------------------------------------------------------------------------------- /lib/net/json/json_decoder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | ///README 4 | /// 5 | ///默认提供了json对应实例化的工具,若需要其他方式解析(如xml,yaml等)则对应需要自行创建解析类进行数据解析 6 | /// 7 | ///如果返回格式为json格式,对应使用本类去解析即可 8 | 9 | ///将json解析成对应的实体类 10 | T? createObjByType(json, Map typeMapper) { 11 | if (json == null || json.toString().isEmpty) { 12 | return null; 13 | } else if (json is Map) { 14 | //如果是对象进行实例化对象解析 15 | return _findObjCreatorFunc(typeMapper)(json); 16 | } else { 17 | //如果不是 则直接返回原始类型 fix 类型是基本数据类型报错的bug 18 | return json; 19 | } 20 | } 21 | 22 | ///[List]对象解析 23 | List fromJSONArray(json, Map typeMapper) { 24 | final list = []; 25 | final function = _findObjCreatorFunc(typeMapper); 26 | try { 27 | json.forEach((itemJson) { 28 | list.add(function(itemJson)); 29 | }); 30 | } catch (e) { 31 | print(e); 32 | } 33 | return list; 34 | } 35 | 36 | Function _findObjCreatorFunc(Map mapper) { 37 | final function = mapper[T]; 38 | if (function == null) { 39 | String typeName = T.toString(); 40 | if (typeName.startsWith('List')) { 41 | print('请使用fromJSONArray函数来解析List对象,接口请使用requestList来请求'); 42 | } else if (typeName.startsWith('PageObj')) { 43 | print('请使用PageObj.fromJson函数来解析PageObj对象,接口请使用requestPage来请求'); 44 | } else if (T == String) { 45 | return (json) => json.toString(); 46 | } else { 47 | debugPrint("--------- json error '没有注册类:$T解析函数'"); 48 | } 49 | throw '没有注册类:$T解析函数'; 50 | } 51 | return function; 52 | } 53 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 44 | source: hosted 45 | version: "1.15.0" 46 | dio: 47 | dependency: "direct main" 48 | description: 49 | name: dio 50 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 51 | source: hosted 52 | version: "4.0.6" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 58 | source: hosted 59 | version: "1.2.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | http_parser: 71 | dependency: transitive 72 | description: 73 | name: http_parser 74 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 75 | source: hosted 76 | version: "4.0.1" 77 | matcher: 78 | dependency: transitive 79 | description: 80 | name: matcher 81 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 82 | source: hosted 83 | version: "0.12.11" 84 | material_color_utilities: 85 | dependency: transitive 86 | description: 87 | name: material_color_utilities 88 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 89 | source: hosted 90 | version: "0.1.3" 91 | meta: 92 | dependency: transitive 93 | description: 94 | name: meta 95 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 96 | source: hosted 97 | version: "1.7.0" 98 | path: 99 | dependency: transitive 100 | description: 101 | name: path 102 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 103 | source: hosted 104 | version: "1.8.0" 105 | sky_engine: 106 | dependency: transitive 107 | description: flutter 108 | source: sdk 109 | version: "0.0.99" 110 | source_span: 111 | dependency: transitive 112 | description: 113 | name: source_span 114 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 115 | source: hosted 116 | version: "1.8.1" 117 | stack_trace: 118 | dependency: transitive 119 | description: 120 | name: stack_trace 121 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 122 | source: hosted 123 | version: "1.10.0" 124 | stream_channel: 125 | dependency: transitive 126 | description: 127 | name: stream_channel 128 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 129 | source: hosted 130 | version: "2.1.0" 131 | string_scanner: 132 | dependency: transitive 133 | description: 134 | name: string_scanner 135 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 136 | source: hosted 137 | version: "1.1.0" 138 | term_glyph: 139 | dependency: transitive 140 | description: 141 | name: term_glyph 142 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 143 | source: hosted 144 | version: "1.2.0" 145 | test_api: 146 | dependency: transitive 147 | description: 148 | name: test_api 149 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 150 | source: hosted 151 | version: "0.4.8" 152 | typed_data: 153 | dependency: transitive 154 | description: 155 | name: typed_data 156 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 157 | source: hosted 158 | version: "1.3.0" 159 | vector_math: 160 | dependency: transitive 161 | description: 162 | name: vector_math 163 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 164 | source: hosted 165 | version: "2.1.1" 166 | sdks: 167 | dart: ">=2.14.0 <3.0.0" 168 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_net 2 | description: A Flutter package for network 3 | version: 1.0.0 4 | environment: 5 | sdk: ">=2.12.0-0 <3.0.0" 6 | 7 | dependencies: 8 | 9 | flutter: 10 | sdk: flutter 11 | #网络请求库 12 | dio: ^4.0.4 13 | 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | 19 | flutter: 20 | 21 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Exceptions to above rules. 43 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 44 | -------------------------------------------------------------------------------- /sample/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 8af6b2f038c1172e61d418869363a28dffec3cb4 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /sample/README.md: -------------------------------------------------------------------------------- 1 | # net_sample 2 | 3 | A new Flutter application sample for net. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /sample/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /sample/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.hikvision.net_sample" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | } 47 | 48 | buildTypes { 49 | release { 50 | // TODO: Add your own signing config for the release build. 51 | // Signing with the debug keys for now, so `flutter run --release` works. 52 | signingConfig signingConfigs.debug 53 | } 54 | } 55 | } 56 | 57 | flutter { 58 | source '../..' 59 | } 60 | 61 | dependencies { 62 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 63 | } 64 | -------------------------------------------------------------------------------- /sample/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 23 | 27 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /sample/android/app/src/main/kotlin/com/hikvision/net_sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.hikvision.net_sample 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /sample/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.30' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /sample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /sample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /sample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | include ':app' 6 | 7 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 8 | def properties = new Properties() 9 | 10 | assert localPropertiesFile.exists() 11 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 12 | 13 | def flutterSdkPath = properties.getProperty("flutter.sdk") 14 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 15 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 16 | -------------------------------------------------------------------------------- /sample/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /sample/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /sample/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /sample/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 97C146F11CF9000F007C117D /* Supporting Files */, 94 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 95 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 96 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 97 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 98 | ); 99 | path = Runner; 100 | sourceTree = ""; 101 | }; 102 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | /* End PBXGroup section */ 110 | 111 | /* Begin PBXNativeTarget section */ 112 | 97C146ED1CF9000F007C117D /* Runner */ = { 113 | isa = PBXNativeTarget; 114 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 115 | buildPhases = ( 116 | 9740EEB61CF901F6004384FC /* Run Script */, 117 | 97C146EA1CF9000F007C117D /* Sources */, 118 | 97C146EB1CF9000F007C117D /* Frameworks */, 119 | 97C146EC1CF9000F007C117D /* Resources */, 120 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 121 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 122 | ); 123 | buildRules = ( 124 | ); 125 | dependencies = ( 126 | ); 127 | name = Runner; 128 | productName = Runner; 129 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 130 | productType = "com.apple.product-type.application"; 131 | }; 132 | /* End PBXNativeTarget section */ 133 | 134 | /* Begin PBXProject section */ 135 | 97C146E61CF9000F007C117D /* Project object */ = { 136 | isa = PBXProject; 137 | attributes = { 138 | LastUpgradeCheck = 1020; 139 | ORGANIZATIONNAME = ""; 140 | TargetAttributes = { 141 | 97C146ED1CF9000F007C117D = { 142 | CreatedOnToolsVersion = 7.3.1; 143 | LastSwiftMigration = 1100; 144 | }; 145 | }; 146 | }; 147 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 148 | compatibilityVersion = "Xcode 9.3"; 149 | developmentRegion = en; 150 | hasScannedForEncodings = 0; 151 | knownRegions = ( 152 | en, 153 | Base, 154 | ); 155 | mainGroup = 97C146E51CF9000F007C117D; 156 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 157 | projectDirPath = ""; 158 | projectRoot = ""; 159 | targets = ( 160 | 97C146ED1CF9000F007C117D /* Runner */, 161 | ); 162 | }; 163 | /* End PBXProject section */ 164 | 165 | /* Begin PBXResourcesBuildPhase section */ 166 | 97C146EC1CF9000F007C117D /* Resources */ = { 167 | isa = PBXResourcesBuildPhase; 168 | buildActionMask = 2147483647; 169 | files = ( 170 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 171 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 172 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 173 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 174 | ); 175 | runOnlyForDeploymentPostprocessing = 0; 176 | }; 177 | /* End PBXResourcesBuildPhase section */ 178 | 179 | /* Begin PBXShellScriptBuildPhase section */ 180 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 181 | isa = PBXShellScriptBuildPhase; 182 | buildActionMask = 2147483647; 183 | files = ( 184 | ); 185 | inputPaths = ( 186 | ); 187 | name = "Thin Binary"; 188 | outputPaths = ( 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | shellPath = /bin/sh; 192 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 193 | }; 194 | 9740EEB61CF901F6004384FC /* Run Script */ = { 195 | isa = PBXShellScriptBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | ); 199 | inputPaths = ( 200 | ); 201 | name = "Run Script"; 202 | outputPaths = ( 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | shellPath = /bin/sh; 206 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 207 | }; 208 | /* End PBXShellScriptBuildPhase section */ 209 | 210 | /* Begin PBXSourcesBuildPhase section */ 211 | 97C146EA1CF9000F007C117D /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 216 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin PBXVariantGroup section */ 223 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C146FB1CF9000F007C117D /* Base */, 227 | ); 228 | name = Main.storyboard; 229 | sourceTree = ""; 230 | }; 231 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 232 | isa = PBXVariantGroup; 233 | children = ( 234 | 97C147001CF9000F007C117D /* Base */, 235 | ); 236 | name = LaunchScreen.storyboard; 237 | sourceTree = ""; 238 | }; 239 | /* End PBXVariantGroup section */ 240 | 241 | /* Begin XCBuildConfiguration section */ 242 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 243 | isa = XCBuildConfiguration; 244 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | CLANG_ANALYZER_NONNULL = YES; 248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 249 | CLANG_CXX_LIBRARY = "libc++"; 250 | CLANG_ENABLE_MODULES = YES; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_COMMA = YES; 255 | CLANG_WARN_CONSTANT_CONVERSION = YES; 256 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 257 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 258 | CLANG_WARN_EMPTY_BODY = YES; 259 | CLANG_WARN_ENUM_CONVERSION = YES; 260 | CLANG_WARN_INFINITE_RECURSION = YES; 261 | CLANG_WARN_INT_CONVERSION = YES; 262 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 263 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 264 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 267 | CLANG_WARN_STRICT_PROTOTYPES = YES; 268 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 269 | CLANG_WARN_UNREACHABLE_CODE = YES; 270 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 271 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 272 | COPY_PHASE_STRIP = NO; 273 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 274 | ENABLE_NS_ASSERTIONS = NO; 275 | ENABLE_STRICT_OBJC_MSGSEND = YES; 276 | GCC_C_LANGUAGE_STANDARD = gnu99; 277 | GCC_NO_COMMON_BLOCKS = YES; 278 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 279 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 280 | GCC_WARN_UNDECLARED_SELECTOR = YES; 281 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 282 | GCC_WARN_UNUSED_FUNCTION = YES; 283 | GCC_WARN_UNUSED_VARIABLE = YES; 284 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 285 | MTL_ENABLE_DEBUG_INFO = NO; 286 | SDKROOT = iphoneos; 287 | SUPPORTED_PLATFORMS = iphoneos; 288 | TARGETED_DEVICE_FAMILY = "1,2"; 289 | VALIDATE_PRODUCT = YES; 290 | }; 291 | name = Profile; 292 | }; 293 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 294 | isa = XCBuildConfiguration; 295 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 296 | buildSettings = { 297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 298 | CLANG_ENABLE_MODULES = YES; 299 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 300 | ENABLE_BITCODE = NO; 301 | FRAMEWORK_SEARCH_PATHS = ( 302 | "$(inherited)", 303 | "$(PROJECT_DIR)/Flutter", 304 | ); 305 | INFOPLIST_FILE = Runner/Info.plist; 306 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 307 | LIBRARY_SEARCH_PATHS = ( 308 | "$(inherited)", 309 | "$(PROJECT_DIR)/Flutter", 310 | ); 311 | PRODUCT_BUNDLE_IDENTIFIER = com.hikvision.netSample; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 314 | SWIFT_VERSION = 5.0; 315 | VERSIONING_SYSTEM = "apple-generic"; 316 | }; 317 | name = Profile; 318 | }; 319 | 97C147031CF9000F007C117D /* Debug */ = { 320 | isa = XCBuildConfiguration; 321 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 322 | buildSettings = { 323 | ALWAYS_SEARCH_USER_PATHS = NO; 324 | CLANG_ANALYZER_NONNULL = YES; 325 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 326 | CLANG_CXX_LIBRARY = "libc++"; 327 | CLANG_ENABLE_MODULES = YES; 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 330 | CLANG_WARN_BOOL_CONVERSION = YES; 331 | CLANG_WARN_COMMA = YES; 332 | CLANG_WARN_CONSTANT_CONVERSION = YES; 333 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INFINITE_RECURSION = YES; 338 | CLANG_WARN_INT_CONVERSION = YES; 339 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 341 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 343 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 344 | CLANG_WARN_STRICT_PROTOTYPES = YES; 345 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 346 | CLANG_WARN_UNREACHABLE_CODE = YES; 347 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 348 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 349 | COPY_PHASE_STRIP = NO; 350 | DEBUG_INFORMATION_FORMAT = dwarf; 351 | ENABLE_STRICT_OBJC_MSGSEND = YES; 352 | ENABLE_TESTABILITY = YES; 353 | GCC_C_LANGUAGE_STANDARD = gnu99; 354 | GCC_DYNAMIC_NO_PIC = NO; 355 | GCC_NO_COMMON_BLOCKS = YES; 356 | GCC_OPTIMIZATION_LEVEL = 0; 357 | GCC_PREPROCESSOR_DEFINITIONS = ( 358 | "DEBUG=1", 359 | "$(inherited)", 360 | ); 361 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 362 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 363 | GCC_WARN_UNDECLARED_SELECTOR = YES; 364 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 365 | GCC_WARN_UNUSED_FUNCTION = YES; 366 | GCC_WARN_UNUSED_VARIABLE = YES; 367 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 368 | MTL_ENABLE_DEBUG_INFO = YES; 369 | ONLY_ACTIVE_ARCH = YES; 370 | SDKROOT = iphoneos; 371 | TARGETED_DEVICE_FAMILY = "1,2"; 372 | }; 373 | name = Debug; 374 | }; 375 | 97C147041CF9000F007C117D /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 378 | buildSettings = { 379 | ALWAYS_SEARCH_USER_PATHS = NO; 380 | CLANG_ANALYZER_NONNULL = YES; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_COMMA = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 390 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 391 | CLANG_WARN_EMPTY_BODY = YES; 392 | CLANG_WARN_ENUM_CONVERSION = YES; 393 | CLANG_WARN_INFINITE_RECURSION = YES; 394 | CLANG_WARN_INT_CONVERSION = YES; 395 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 397 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 398 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 399 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 400 | CLANG_WARN_STRICT_PROTOTYPES = YES; 401 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 402 | CLANG_WARN_UNREACHABLE_CODE = YES; 403 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 404 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 405 | COPY_PHASE_STRIP = NO; 406 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 407 | ENABLE_NS_ASSERTIONS = NO; 408 | ENABLE_STRICT_OBJC_MSGSEND = YES; 409 | GCC_C_LANGUAGE_STANDARD = gnu99; 410 | GCC_NO_COMMON_BLOCKS = YES; 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 418 | MTL_ENABLE_DEBUG_INFO = NO; 419 | SDKROOT = iphoneos; 420 | SUPPORTED_PLATFORMS = iphoneos; 421 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 422 | TARGETED_DEVICE_FAMILY = "1,2"; 423 | VALIDATE_PRODUCT = YES; 424 | }; 425 | name = Release; 426 | }; 427 | 97C147061CF9000F007C117D /* Debug */ = { 428 | isa = XCBuildConfiguration; 429 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | CLANG_ENABLE_MODULES = YES; 433 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 434 | ENABLE_BITCODE = NO; 435 | FRAMEWORK_SEARCH_PATHS = ( 436 | "$(inherited)", 437 | "$(PROJECT_DIR)/Flutter", 438 | ); 439 | INFOPLIST_FILE = Runner/Info.plist; 440 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 441 | LIBRARY_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "$(PROJECT_DIR)/Flutter", 444 | ); 445 | PRODUCT_BUNDLE_IDENTIFIER = com.hikvision.netSample; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 448 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 449 | SWIFT_VERSION = 5.0; 450 | VERSIONING_SYSTEM = "apple-generic"; 451 | }; 452 | name = Debug; 453 | }; 454 | 97C147071CF9000F007C117D /* Release */ = { 455 | isa = XCBuildConfiguration; 456 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 457 | buildSettings = { 458 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 459 | CLANG_ENABLE_MODULES = YES; 460 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 461 | ENABLE_BITCODE = NO; 462 | FRAMEWORK_SEARCH_PATHS = ( 463 | "$(inherited)", 464 | "$(PROJECT_DIR)/Flutter", 465 | ); 466 | INFOPLIST_FILE = Runner/Info.plist; 467 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 468 | LIBRARY_SEARCH_PATHS = ( 469 | "$(inherited)", 470 | "$(PROJECT_DIR)/Flutter", 471 | ); 472 | PRODUCT_BUNDLE_IDENTIFIER = com.hikvision.netSample; 473 | PRODUCT_NAME = "$(TARGET_NAME)"; 474 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 475 | SWIFT_VERSION = 5.0; 476 | VERSIONING_SYSTEM = "apple-generic"; 477 | }; 478 | name = Release; 479 | }; 480 | /* End XCBuildConfiguration section */ 481 | 482 | /* Begin XCConfigurationList section */ 483 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 97C147031CF9000F007C117D /* Debug */, 487 | 97C147041CF9000F007C117D /* Release */, 488 | 249021D3217E4FDB00AE95B9 /* Profile */, 489 | ); 490 | defaultConfigurationIsVisible = 0; 491 | defaultConfigurationName = Release; 492 | }; 493 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | 97C147061CF9000F007C117D /* Debug */, 497 | 97C147071CF9000F007C117D /* Release */, 498 | 249021D4217E4FDB00AE95B9 /* Profile */, 499 | ); 500 | defaultConfigurationIsVisible = 0; 501 | defaultConfigurationName = Release; 502 | }; 503 | /* End XCConfigurationList section */ 504 | }; 505 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 506 | } 507 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jimmuy/flutter_net/15825d4ac938aa28e30511e3bf19b0e424b64b42/sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /sample/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /sample/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /sample/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sample/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | net_sample 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /sample/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /sample/lib/bean/bean.dart: -------------------------------------------------------------------------------- 1 | ///https://javiercbk.github.io/json_to_dart/ use this website to decode json string 2 | 3 | class GetSampleBean { 4 | Rating? rating; 5 | String? subtitle; 6 | List? author; 7 | 8 | GetSampleBean({this.rating, this.subtitle, this.author}); 9 | 10 | GetSampleBean.fromJson(Map json) { 11 | rating = Rating.fromJson(json['rating']); 12 | subtitle = json['subtitle']; 13 | author = json['author'].cast(); 14 | } 15 | 16 | Map toJson() { 17 | final Map data = new Map(); 18 | if (this.rating != null) { 19 | data['rating'] = this.rating?.toJson(); 20 | } 21 | data['subtitle'] = this.subtitle; 22 | data['author'] = this.author; 23 | return data; 24 | } 25 | } 26 | 27 | class Rating { 28 | int? max; 29 | int? numRaters; 30 | String? average; 31 | int? min; 32 | 33 | Rating({this.max, this.numRaters, this.average, this.min}); 34 | 35 | Rating.fromJson(Map json) { 36 | max = json['max']; 37 | numRaters = json['numRaters']; 38 | average = json['average']; 39 | min = json['min']; 40 | } 41 | 42 | Map toJson() { 43 | final Map data = new Map(); 44 | data['max'] = this.max; 45 | data['numRaters'] = this.numRaters; 46 | data['average'] = this.average; 47 | data['min'] = this.min; 48 | return data; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sample/lib/bean/page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_net/net/json/json_decoder.dart'; 2 | import 'package:net_sample/json/mapper.dart'; 3 | 4 | ///分页逻辑的实体类,如分页方式与字段不同,最好使用PageObj作为类名,解析错误的话会有错误提示(非必须) 5 | class PageObj { 6 | int pageNo = 0; 7 | int pageSize = 20; 8 | int? totalPage; 9 | int? total; 10 | bool? hasNextPage; 11 | bool? hasPreviousPage; 12 | bool? firstPage; 13 | bool? lastPage; 14 | List rows = []; 15 | 16 | PageObj(); 17 | 18 | PageObj.fromJson(Map json) { 19 | this.pageNo = json['pageNo']; 20 | this.pageSize = json['pageSize']; 21 | this.totalPage = json['totalPage']; 22 | this.total = json['total']; 23 | this.hasNextPage = json['hasNextPage']; 24 | this.hasPreviousPage = json['hasPreviousPage']; 25 | this.firstPage = json['firstPage']; 26 | this.lastPage = json['lastPage']; 27 | rows = fromJSONArray(json['rows'] ?? [], objectMapper); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sample/lib/json/mapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:net_sample/bean/bean.dart'; 2 | 3 | ///维护Type和Creator的对应关系 4 | final objectMapper = { 5 | GetSampleBean: (json) => GetSampleBean.fromJson(json), 6 | String: (json) => json.toString(), 7 | }; 8 | -------------------------------------------------------------------------------- /sample/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_net/net/constant/net_const.dart'; 5 | import 'package:flutter_net/net/error/net_exception.dart'; 6 | 7 | import 'bean/bean.dart'; 8 | import 'manager/net_manager.dart'; 9 | 10 | void main() { 11 | ///这个因为mock接口过期了所以加了一个跳过证书的操作,正常情况下不需要添加此行代码 12 | HttpOverrides.global = new MyHttpOverrides(); 13 | runApp(MyApp()); 14 | } 15 | 16 | class MyApp extends StatelessWidget { 17 | // This widget is the root of your application. 18 | @override 19 | Widget build(BuildContext context) { 20 | return MaterialApp( 21 | title: 'Flutter Net Sample', 22 | theme: ThemeData( 23 | primarySwatch: Colors.blue, 24 | visualDensity: VisualDensity.adaptivePlatformDensity, 25 | ), 26 | home: MyHomePage(title: 'Flutter Net Sample'), 27 | ); 28 | } 29 | } 30 | 31 | class MyHomePage extends StatefulWidget { 32 | MyHomePage({this.title}) : super(); 33 | final String? title; 34 | 35 | @override 36 | _MyHomePageState createState() => _MyHomePageState(); 37 | } 38 | 39 | class _MyHomePageState extends State { 40 | String? _content = ""; 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | return Scaffold( 45 | appBar: AppBar( 46 | title: Text(widget.title ?? ""), 47 | ), 48 | body: Center( 49 | child: Column( 50 | children: [ 51 | InkWell( 52 | onTap: () => sendGetRequest(), 53 | child: Container( 54 | alignment: Alignment.center, 55 | height: 50, 56 | margin: EdgeInsets.only(top: 20, left: 16, right: 16), 57 | color: Colors.blue[300], 58 | child: Text( 59 | '点击发送GET/POST/PUT/DELETE等请求', 60 | style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), 61 | ), 62 | ), 63 | ), 64 | InkWell( 65 | onTap: () => sendPageRequest(), 66 | child: Container( 67 | alignment: Alignment.center, 68 | height: 50, 69 | margin: EdgeInsets.only(top: 20, left: 16, right: 16), 70 | color: Colors.blue[300], 71 | child: Text( 72 | '点击发送分页请求', 73 | style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), 74 | ), 75 | ), 76 | ), 77 | InkWell( 78 | onTap: () => sendListRequest(), 79 | child: Container( 80 | alignment: Alignment.center, 81 | height: 50, 82 | margin: EdgeInsets.only(top: 20, left: 16, right: 16), 83 | color: Colors.blue[300], 84 | child: Text( 85 | '点击发送列表请求', 86 | style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), 87 | ), 88 | ), 89 | ), 90 | Container( 91 | alignment: Alignment.center, 92 | height: 30, 93 | margin: EdgeInsets.only(top: 20), 94 | color: Colors.blue[100], 95 | child: Text( 96 | '此sample为上层应用使用网络框架的示例用法,仅供参考', 97 | style: TextStyle(color: Colors.white, fontSize: 12), 98 | ), 99 | ), 100 | Expanded( 101 | child: Container( 102 | alignment: Alignment.center, 103 | margin: EdgeInsets.all(16), 104 | child: Text( 105 | _content ?? "", 106 | style: Theme.of(context).textTheme.headline6, 107 | ), 108 | ), 109 | ), 110 | ], 111 | ), 112 | ), 113 | ); 114 | } 115 | 116 | sendPageRequest() { 117 | setState(() { 118 | _content = "loading..."; 119 | }); 120 | 121 | requestPage("/flutter_test/post", method: Method.POST) 122 | .then((value) => { 123 | setState(() { 124 | _content = "分页请求解析字段average值为: ${value.rows[0].rating?.average}"; 125 | }) 126 | }) 127 | .catchError((error) { 128 | //错误处理,可以封装成顶层函数方便调用 129 | if (error is NetWorkException) { 130 | setState(() { 131 | _content = error.message; 132 | }); 133 | } 134 | }).whenComplete(() => { 135 | //请求结束后,类似于finally,成功失败一定会走,在这里hideLoading 136 | }); 137 | } 138 | 139 | sendGetRequest() { 140 | setState(() { 141 | _content = "loading..."; 142 | }); 143 | get("/flutter_test/get") 144 | .then((value) => { 145 | setState(() { 146 | _content = "GET接口解析字段average值为: $value"; 147 | }) 148 | }) 149 | .catchError((error) { 150 | //错误处理,可以封装成顶层函数方便调用 151 | if (error is NetWorkException) { 152 | setState(() { 153 | _content = error.message; 154 | }); 155 | } 156 | }).whenComplete(() => { 157 | //请求结束后,类似于finally,成功失败一定会走,在这里hideLoading 158 | }); 159 | } 160 | 161 | sendListRequest() { 162 | setState(() { 163 | _content = "loading..."; 164 | }); 165 | requestList("/flutter_test/get_list") 166 | .then((value) => { 167 | setState(() { 168 | _content = "GET_LIST接口解析得到的数组第一个值为: ${value[0]}"; 169 | }) 170 | }) 171 | .catchError((error) { 172 | //错误处理,可以封装成顶层函数方便调用 173 | if (error is NetWorkException) { 174 | setState(() { 175 | _content = error.message; 176 | }); 177 | } 178 | }).whenComplete(() => { 179 | //请求结束后,类似于finally,成功失败一定会走,在这里hideLoading 180 | }); 181 | } 182 | } 183 | 184 | ///处理证书过期 185 | class MyHttpOverrides extends HttpOverrides { 186 | @override 187 | HttpClient createHttpClient(SecurityContext? context) { 188 | return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true; 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /sample/lib/manager/net_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_net/net/flutter_net.dart'; 2 | import 'package:net_sample/bean/page.dart'; 3 | import 'package:net_sample/json/mapper.dart'; 4 | 5 | /// 简化网络请求而封装的顶层函数 6 | 7 | ///get 请求 8 | Future get(String url, {params, Options? options, cancelToken}) async { 9 | return NetManager.getInstance().get(url, params: params, options: options, token: cancelToken); 10 | } 11 | 12 | ///post 请求 13 | Future post(String url, {params, options, cancelToken}) async { 14 | return NetManager.getInstance().post(url, params: params, options: options, token: cancelToken); 15 | } 16 | 17 | ///delete 请求 18 | Future delete(String url, {params, options, cancelToken}) async { 19 | return NetManager.getInstance().delete(url, params: params, options: options, token: cancelToken); 20 | } 21 | 22 | ///put 请求 23 | Future put(String url, {params, options, cancelToken}) async { 24 | return NetManager.getInstance().put(url, params: params, options: options, token: cancelToken); 25 | } 26 | 27 | ///当网络请求返回格式为{"code":0,"msg":"OK","data":[]}形式的时候,使用requestList请求数据 28 | Future> requestList( 29 | String url, { 30 | Method method: Method.GET, 31 | params, 32 | options, 33 | token, 34 | }) async { 35 | return NetManager.getInstance().requestHttp>( 36 | url, 37 | method, 38 | params: params, 39 | options: options, 40 | cancelToken: token, 41 | decode: (json) => fromJSONArray(json, objectMapper), 42 | ); 43 | } 44 | 45 | ///当网络请求返回格式为分页格式的时候,requestPage,分页的数据结构为PageObj仅供参考 46 | Future> requestPage( 47 | String url, { 48 | Method method: Method.GET, 49 | params, 50 | options, 51 | token, 52 | }) async { 53 | return NetManager.getInstance().requestHttp>( 54 | url, 55 | method, 56 | params: params, 57 | options: options, 58 | cancelToken: token, 59 | decode: (json) => PageObj.fromJson(json), 60 | ); 61 | } 62 | 63 | ///单例形式使用 64 | class NetManager extends DioManager { 65 | NetManager._(); 66 | 67 | static NetManager? _instance; 68 | 69 | static NetManager getInstance() { 70 | if (_instance == null) { 71 | _instance = NetManager._(); 72 | } 73 | return _instance!; 74 | } 75 | 76 | @override 77 | T? decode(response) => createObjByType(response, objectMapper); 78 | 79 | @override 80 | String getBaseUrl() { 81 | return "https://mock.mengxuegu.com/mock/6073b60856076a4a7648458e/example"; 82 | } 83 | 84 | @override 85 | bool isSuccess(Response response) { 86 | return response.data['code'] == HttpCode.SUCCESS; 87 | } 88 | 89 | @override 90 | NetWorkException getBusinessErrorResult(int code, String error, T data) { 91 | return super.getBusinessErrorResult(code, error, data); 92 | } 93 | 94 | @override 95 | NetWorkException getHttpErrorResult(DioError e) { 96 | NetWorkException httpErrorResult = super.getHttpErrorResult(e); 97 | print("-----------------------HTTP ERROR ${httpErrorResult.data}"); 98 | return httpErrorResult; 99 | } 100 | 101 | @override 102 | bool isShowLog() => true; 103 | 104 | @override 105 | void logout() {} 106 | } 107 | -------------------------------------------------------------------------------- /sample/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 44 | source: hosted 45 | version: "1.15.0" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 51 | source: hosted 52 | version: "0.1.3" 53 | dio: 54 | dependency: transitive 55 | description: 56 | name: dio 57 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 58 | source: hosted 59 | version: "4.0.6" 60 | fake_async: 61 | dependency: transitive 62 | description: 63 | name: fake_async 64 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 65 | source: hosted 66 | version: "1.2.0" 67 | flutter: 68 | dependency: "direct main" 69 | description: flutter 70 | source: sdk 71 | version: "0.0.0" 72 | flutter_net: 73 | dependency: "direct main" 74 | description: 75 | path: ".." 76 | relative: true 77 | source: path 78 | version: "1.0.0" 79 | flutter_test: 80 | dependency: "direct dev" 81 | description: flutter 82 | source: sdk 83 | version: "0.0.0" 84 | http_parser: 85 | dependency: transitive 86 | description: 87 | name: http_parser 88 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 89 | source: hosted 90 | version: "4.0.1" 91 | matcher: 92 | dependency: transitive 93 | description: 94 | name: matcher 95 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 96 | source: hosted 97 | version: "0.12.11" 98 | material_color_utilities: 99 | dependency: transitive 100 | description: 101 | name: material_color_utilities 102 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 103 | source: hosted 104 | version: "0.1.3" 105 | meta: 106 | dependency: transitive 107 | description: 108 | name: meta 109 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 110 | source: hosted 111 | version: "1.7.0" 112 | path: 113 | dependency: transitive 114 | description: 115 | name: path 116 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 117 | source: hosted 118 | version: "1.8.0" 119 | sky_engine: 120 | dependency: transitive 121 | description: flutter 122 | source: sdk 123 | version: "0.0.99" 124 | source_span: 125 | dependency: transitive 126 | description: 127 | name: source_span 128 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 129 | source: hosted 130 | version: "1.8.1" 131 | stack_trace: 132 | dependency: transitive 133 | description: 134 | name: stack_trace 135 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 136 | source: hosted 137 | version: "1.10.0" 138 | stream_channel: 139 | dependency: transitive 140 | description: 141 | name: stream_channel 142 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 143 | source: hosted 144 | version: "2.1.0" 145 | string_scanner: 146 | dependency: transitive 147 | description: 148 | name: string_scanner 149 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 150 | source: hosted 151 | version: "1.1.0" 152 | term_glyph: 153 | dependency: transitive 154 | description: 155 | name: term_glyph 156 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 157 | source: hosted 158 | version: "1.2.0" 159 | test_api: 160 | dependency: transitive 161 | description: 162 | name: test_api 163 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 164 | source: hosted 165 | version: "0.4.8" 166 | typed_data: 167 | dependency: transitive 168 | description: 169 | name: typed_data 170 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 171 | source: hosted 172 | version: "1.3.0" 173 | vector_math: 174 | dependency: transitive 175 | description: 176 | name: vector_math 177 | url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" 178 | source: hosted 179 | version: "2.1.1" 180 | sdks: 181 | dart: ">=2.14.0 <3.0.0" 182 | -------------------------------------------------------------------------------- /sample/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: net_sample 2 | description: A new Flutter application sample for net. 3 | 4 | version: 1.0.0+1 5 | 6 | environment: 7 | sdk: ">=2.12.0-0 <3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | flutter_net: 13 | path: ../../ym_flutter_net 14 | 15 | cupertino_icons: ^0.1.3 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | 21 | flutter: 22 | 23 | uses-material-design: true 24 | --------------------------------------------------------------------------------