{"id":32280185,"url":"https://github.com/zhengzaihong/rxnet","last_synced_at":"2026-02-22T18:01:42.419Z","repository":{"id":57749303,"uuid":"521215063","full_name":"zhengzaihong/rxnet","owner":"zhengzaihong","description":"RxNet 是一款专为 Flutter 开发的跨平台网络请求工具，贴合原生开发习惯，几乎零学习成本即可上手。它不仅让网络通信更丝滑，还支持丰富的功能组合，助你构建高性能、可维护的移动应用，已经支持Android、ios、windows、linux、macos、Web、HarmonyOS","archived":false,"fork":false,"pushed_at":"2025-12-30T06:56:52.000Z","size":2454,"stargazers_count":49,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-15T11:16:13.155Z","etag":null,"topics":["android","cache","dart","dio","flutter","harmonyos","harmonyos-next","http","http-client","https","ios","network","request","web","windows"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhengzaihong.png","metadata":{"files":{"readme":"README-ZH.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-08-04T10:05:00.000Z","updated_at":"2026-01-21T16:37:14.000Z","dependencies_parsed_at":"2024-01-12T06:29:30.119Z","dependency_job_id":"6a4df838-de72-4972-a3c2-db0628ad1add","html_url":"https://github.com/zhengzaihong/rxnet","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"a54f96bc7bbaef226540c2bc2e3261752334004e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhengzaihong/rxnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengzaihong%2Frxnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengzaihong%2Frxnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengzaihong%2Frxnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengzaihong%2Frxnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhengzaihong","download_url":"https://codeload.github.com/zhengzaihong/rxnet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengzaihong%2Frxnet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29721050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T15:10:41.462Z","status":"ssl_error","status_checked_at":"2026-02-22T15:10:04.636Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cache","dart","dio","flutter","harmonyos","harmonyos-next","http","http-client","https","ios","network","request","web","windows"],"created_at":"2025-10-23T00:41:25.280Z","updated_at":"2026-02-22T18:01:42.405Z","avatar_url":"https://github.com/zhengzaihong.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxNet\n\n[![pub package](https://img.shields.io/pub/v/rxnet_plus.svg)](https://pub.dev/packages/rxnet_plus)\n[![GitHub stars](https://img.shields.io/github/stars/zhengzaihong/rxnet.svg?style=social)](https://github.com/zhengzaihong/rxnet)\n[![license](https://img.shields.io/github/license/zhengzaihong/rxnet)](LICENSE)\n\nLanguage: [English](README.md) | 简体中文\n\n🚀 RxNet：极简易用、强大、原生风格的 Flutter 网络通信框架\nRxNet 是一款专为 Flutter 打造的跨平台网络请求工具，基于 Dio 深度封装，贴合原生开发习惯，几乎零学习成本即可上手。可轻松实现开屏即有数据特性，支持丰富的功能组合，助你构建高性能、可维护的应用程序。\n\n## 🎉 0.5.0 重大更新\n\nRxNet 0.5.0 带来了更多全新的API设计，大幅提升代码可读性和开发体验！\n\n\n📖 **详细迁移指南：** [迁移指南_0.5.0.md](迁移指南_0.5.0.md)\n\n🌟 核心亮点：\n\n✅ 多种缓存策略：支持首次缓存、失败兜底、仅缓存等多种模式，灵活应对各种场景\n\n🔁 断点续传：上传/下载支持断点恢复，轻松处理大文件传输\n\n🔄 轮询请求：无需额外维护队列，轻松实现定时拉取\n\n🔥 RESTful 风格支持：参数自动拼接，URL更清晰\n\n🧠 JSON → 实体自动转换：支持 setJsonConvert，轻松对接后端数据模型\n\n🧩 全局拦截器与异常捕获：统一处理请求逻辑与错误反馈\n\n🧪 支持 async/await 与响应回调双模式：满足不同开发习惯\n\n🧰 内置日志控制台 UI：调试更直观，线上问题快速定位\n\n📦 轻量键值存储：替代 SharedPreferences，更高效\n\n## 依赖：\n\n    dependencies:\n       rxnet_plus: ^0.5.0  // 最新版本，全新API设计\n       # rxnet_plus: ^0.4.3  // 旧版本\n       # flutter_rxnet_forzzh: ^0.4.0  // 更旧的版本（不再维护）\n\n\n**从0.4.3升级到0.5.0？** 查看 [迁移指南](迁移指南_0.5.0.md)\n\n\n## 常用参数：\n\n### 支持的请求方式：`get, post, delete, put, patch`,\n\n缓存策略：CacheMode 支持如下几种模式：\n\n```dart\nenum CacheMode {\n\n    //不做缓存，每次都发起请求\n    ONLY_REQUEST,\n    \n    //只使用缓存，通常用于先预加载数据，切换到无网环境做数据显示\n    ONLY_CACHE,\n    \n    //先请求网络，如果请求网络失败，则读取缓存，如果读取缓存失败，本次请求失败\n    REQUEST_FAILED_READ_CACHE,\n    \n    //先使用缓存显示，不管是否存在，仍然请求网络，新数据替换缓存数据，并触发上次数据刷新\n    FIRST_USE_CACHE_THEN_REQUEST,\n    \n    //先使用缓存，无缓存或缓存过期后再请求网络，否则不会请求网络\n    CACHE_EMPTY_OR_EXPIRED_THEN_REQUEST,\n}\n\n```\n\n⚠️注意：\n\n1.不设置 `setJsonConvert` 返回的都原始类型数据，否则返回定义的实体类型。\n\n2.需要json 转对象，请设置 setJsonConvert 并在回调中根据后端返回统一格式进行转换。\n\n#### 额外功能：小量数据支持 RxNet 数据来存储,效率更高效：\n\n```dart\n  \n//存储数据 key-value\nRxNet.saveCache(\"name\", \"张三\");\n\n//读取数据\nRxNet.readCache(\"name\").then((value) {\n  LogUtil.v(value);  //输出：张三\n});\n\n//或者\nFuture.delayed(const Duration(seconds: 5),() async{\n  final result = await RxNet.readCache(\"name\");\n  LogUtil.v(result);  //输出：张三\n});\n```\n\n#### 注意：Web端不支持额外数据存储。\n\n#### 执行请求的几种方式，请结合场景使用：\n```dart\n\n1.方式一 ：RxNet.execute(success,failure,completed)\n  Success 回调中获取最终数据。\n  Failure 回调中获取错误信息。\n  Completed 始终都会执行的回调，取消加载动画，释放资源等\n\n\n2.方式二  await RxNet.request()\n  返回结果或错误信息都在 RxResult 实体中，无需try catch操作。\n  RxResult.value 获取最终结果。\n  RxResult.error 获取错误信息\n\n3.方式三  await RxNet.executeStream()\n  返回结果或错误信息都在 RxResult 实体中。\n  RxResult.value 获取最终结果。\n  RxResult.error 获取错误信息\n```\n\n## 服用说明：\n \n ### 初始化网络框架\n```dart\n await RxNet.init(\n    baseUrl: \"http://t.weather.sojson.com/\",\n    // cacheDir: \"xxx\",   ///缓存目录\n    // cacheName: \"local_cache\", ///缓存文件\n    baseCacheMode: CacheMode.REQUEST_FAILED_READ_CACHE, //请求失败读取缓存数据\n    baseCheckNet:checkNet, //全局检查网络，所有的请求都走这个方法\n    cacheInvalidationTime: 24 * 60 * 60 * 1000, //缓存时效毫秒\n    // baseUrlEnv: {  ///支持多环境 baseUrl调试，RxNet.setDefaultEnv(\"test\") 方式切换;\n    //   \"test\": \"http://t.weather.sojson1.com/\",\n    //   \"debug\": \"http://t.weather.sojson2.com/\",\n    //   \"release\": \"http://t.weather.sojson.com/\",\n    // },\n    interceptors: [\n      // TokenInterceptor // token拦截器，更多功能请自定义拦截器\n      //日志拦截器\n       RxNetLogInterceptor()\n      //ResponseInterceptor() //自定义响应拦截器，预处理结果等\n    ]);\n```\n\n ### 发起网络请求（ post, get, delete, put, patch等同理）这里get举例：\n\n###    1.回调模式：\n```dart\n\nRxNet.get()\n    .setPath('api/weather/city/{id}')\n    .setPathParam(\"id\", \"101030100\") //RESTFul时，这里的参数名称需要和路径中占位符保持一直:最终地址：http://t.weather.sojson.com/api/weather/city/101030100\n    .setCancelToken(pageRequestToken) //取消请求的CancelToken\n    .setCacheMode(CacheMode.CACHE_EMPTY_OR_EXPIRED_THEN_REQUEST)\n    //.setRetryCount(2, interval: const Duration(seconds: 7))  //失败重试，重试2次,每次间隔7秒\n    //.setLoop(true, interval: const Duration(seconds: 5)) // 定时请求\n    //.setContentType(ContentTypes.json) //application/json\n    //.setResponseType(ResponseType.json) //json\n    //.setCacheInvalidationTime(1000*10)  //本次请求的缓存失效时间-毫秒\n    //.setRequestIgnoreCacheTime(true)  //是否直接忽略缓存失效时间\n    .setJsonConvert(NewWeatherInfo.fromJson) //解析成NewWeatherInfo对象\n    // .setJsonConvert((data)=\u003e BaseBean\u003cData\u003e.fromJson(data).data) // 如果你只关心data实体部分\n    // .setJsonConvert((data)=\u003e BaseInfo\u003cData\u003e.fromJson(data, Data.fromJson)) //如果你想要 code 等信息\n    //.setJsonConvert((data)=\u003eBaseInfo\u003cData\u003e.fromJson(data, Data.fromJson).data) //如果你只关心data实体部分\n    .execute\u003cNewWeatherInfo\u003e(\n        success: (data, source) {\n          //刷新UI\n          count++;\n          setState(() {\n            content =\"$count : ${jsonEncode(data)}\";\n            sourcesType = source;\n          });\n         },\n        failure: (e) {\n          setState(() {\n            content = \"empty data\";\n          });\n         },\n        completed: (){\n          //请求成功或失败后始终都会执行的回调，用于取消加载动画等\n     });\n```\n\n###   2. async/await方式：\n```dart\n var data = await RxNet.get()  \n    .setPath(\"api/weather/{id}\") //RESTFul时，这里的参数名称需要和路径中占位符保持一致:最终地址：http://t.weather.sojson.com/api/weather/101030100\n    .setPathParam(\"city\", \"101030100\")\n    //.setQueryParams(Map) //一次添加多个参数\n    //.setRetryCount(2)  //重试次数\n    .setCacheMode(CacheMode.ONLY_REQUEST)\n    //.setJsonConvert((data) =\u003e NormalWaterInfoEntity.fromJson(data)) //解析成NormalWaterInfoEntity对象\n    .setJsonConvert(NormalWaterInfoEntity.fromJson)\n    .request\u003cNormalWaterInfoEntity\u003e();\n\n  print(\"---------\u003e#${data.error}\");\n  var result = data.value;\n  content = result.toString();\n  sourcesType = data.model;\n```\n\n###   3. Stream 流式：\n```dart\n//用于取消的句柄\nStreamSubscription? _subscription;\n\nvoid testStreamRequest(){\n\n  final pollingSubscription = RxNet.get()\n       .setPath(\"api/weather/{id}\")\n       .setParam(\"city\", \"101030100\")\n       .setLoop(true, interval: const Duration(seconds: 7))\n       .executeStream(); // 直接使用 executeStream\n   //     .listen((data) {\n   //       setState(() {\n   //         count++;\n   //         if (data.isSuccess) {\n   //           var result = data.value;\n   //           content =count.toString() +\" : \"+ jsonEncode(result);\n   //           sourcesType = data.model;\n   //         } else {\n   //           content = data.error.toString();\n   //         }\n   //       });\n   // });\n   // 或者使用如下方式：\n  _subscription = pollingSubscription.listen((data){\n           setState(() {\n             count++;\n             if (data.isSuccess) {\n               var result = data.value;\n               content =\"$count : ${jsonEncode(result)}\";\n               sourcesType = data.model;\n             } else {\n               content = data.error.toString();\n             }\n           });\n   });\n\n}\n```\n\n 注意：方式三中，在不使用时需及时取消订阅：\n\n```dart\n    @override\n    void dispose() {\n     _subscription?.cancel();\n     _cancelToken?.cancel();\n      super.dispose();\n    }\n```\n\n⚠️特别说明：\n\n 无论使用那种请求方式，本质上都是 Stream,当轮询启用时，async/await 只返回首次的结果,底层流将被取消。\n 如要获得所有响应结果，你必须使用execute（）或者直接监听executeStream（）。\n\n 1.方式1中的success第二个参数和RxResult中的Model说明了数据来源：网络/缓存。\n\n 2.使用方式三时，在不需需要时，及时关闭订阅：_subscription?.cancel()\n\n 3.当页面需要退出时，或者不在关系请求结果时，可通过设置的CancelToken取消请求。\n\n\n ### 上传下载(支持断点上传下载)：注意移动终端的文件读写权限。\n\n```dart\n  \nRxNet.get() \n    .setPath(\"https://img2.woyaogexing.com/2022/08/02/b3b98b98ec34fb3b!400x400.jpg\")\n    .setParam(xx,xx)\n     //breakPointDownload() 断点下载\n    .download(\n      savePath:\"${appDocPath}/55.jpg\",\n      onReceiveProgress: (len,total){\n        print(\"len:$len,total:$total\");\n        if(len ==total){\n          downloadPath = appDocPath;\n        }\n      });\n\n\n\nRxNet.post()\n    .setPath(\"xxxxx/xxx.jpg\")\n    // breakPointUpload() 断点续传\n    .upload(\n        success: (data, sourcesType) {},\n        failure: (e) {},\n        onSendProgress: (len, total) {});\n```\n\n### 配置全局请求头的方式\n\n 1.setGlobalHeaders(Map\u003cString, dynamic\u003e headers) 方式:\n\n```dart\nRxNet.setGlobalHeaders({\n \"Accept-Encoding\": \"gzip, deflate, br\",\n \"Connection\": \"keep-alive\",\n});     \n```\n\n 2.添加自定义请求拦截器 xxxInterceptor() 如：\n\n```dart\n\n class TokenInterceptors extends Interceptor {\n  @override\n  onRequest( RequestOptions options, RequestInterceptorHandler handler) async {\n    Map\u003cString, dynamic\u003e header = {};\n    header[\"token\"] = \"xxxxx\";\n    header[\"version\"] = \"1.0\";\n    options.headers.addAll(header);\n    handler.next(options);\n  }\n}\n\n```\n\n\n### 如果你的业务或项目中需要多个网络请求实例可手动创建多个请求对象：\n```dart\n\nvoid newInstanceRequest() async {\n  // 为这个实例进行独立的初始化配置，请求策略，拦截器等等\n  final apiService = RxNet.create();\n  await apiService.initNet(baseUrl: \"https://api.yourdomain.com\");\n  // apiService.setHeaders(xxx)\n  final response = await apiService.getRequest()\n      .setPath(\"/users/1\")\n      .setJsonConvert(NewWeatherInfo.fromJson)\n      .request();\n\n  final weatherInfo = response.value;\n}\n```\n\n\n### 请求前的网络检测：  \n```dart\n //无论是默认的请求实例，还是手动创建的多实例 配置了 baseCheckNet，则每次请求都会网络检测\nawait RxNet.init(\n    baseUrl: \"xxxx\",\n    baseCacheMode: CacheMode.REQUEST_FAILED_READ_CACHE, //请求失败读取缓存数据\n    baseCheckNet:checkNet, //全局检查网络，所有的请求都走这个方法\n   );\n\n例如：\n\nFuture\u003cbool\u003e checkNet() async{\n  //需自行实现网络检测，或使用三方库\n  var connectivityResult = await (Connectivity().checkConnectivity());\n  if (connectivityResult == ConnectivityResult.none) {\n    Toast.show( \"当前无网络\");\n    return false;\n  }\n  return Future.value(true);\n}\n```\n\n### 证书校验：\n```dart\nRxNet.getDefaultClient()?.httpClientAdapter = IOHttpClientAdapter(\n  createHttpClient: () {\n    final client = HttpClient();\n    // 在这里进行自定义配置，例如证书校验等：\n    // 设置为 false，表示默认拒绝所有无效证书\n    client.badCertificateCallback = (X509Certificate cert, String host, int port) {\n      // 你可以在这里添加更复杂的校验逻辑，例如校验证书指纹或颁发机构\n      // 你的可能是xx.pem 等文件，读取出来再校验\n      const trustedFingerprint = 'AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12';\n      final certFingerprint = cert.sha1.toString().toUpperCase();\n      final isTrusted = certFingerprint == trustedFingerprint;\n      // 只有当证书可信时才允许请求\n      return isTrusted;\n    };\n    return client;\n  },\n);\n```\n\n### 清晰的日志拦截器，拒绝调试抓瞎。\n     \n    需要日志信息，初始化配置网络框架时请添加 RxNetLogInterceptor 拦截器 或者您自定义的\n```dart\n await RxNet.init(\n    // xxxxxx\n    interceptors: [\n      //TokenInterceptor // token拦截器，更多功能请自定义拦截器\n      ///日志拦截器\n       RxNetLogInterceptor()\n       //ResponseInterceptor() //响应拦截器，预处理结果\n    ]);\n```\n\n   输出格式：\n```dart\n[log] ###日志：  v  ***************** Request Start *****************\n[log] ###日志：  v  uri: http://t.weather.sojson.com/api/weather/city/101030100\n[log] ###日志：  v  method: GET\n[log] ###日志：  v  responseType: ResponseType.json\n[log] ###日志：  v  followRedirects: true\n[log] ###日志：  v  connectTimeout:\n[log] ###日志：  v  receiveTimeout:\n[log] ###日志：  v  extra: {}\n[log] ###日志：  v  Request Headers:\n[log] ###日志：  v  {\"content-type\":\"application/json\"}\n[log] ###日志：  v  data:\n[log] ###日志：  v  null\n[log] ###日志：  v  ***************** Request End *****************\n[log] ###日志：  v  ***************** Response Start *****************\n[log] ###日志：  v  statusCode: 200\n[log] ###日志：  v  Response Headers:\n[log] ###日志：  v   connection: keep-alive\n[log] ###日志：  v   cache-control: max-age=3000\n[log] ###日志：  v   transfer-encoding: chunked\n[log] ###日志：  v   date: Wed, 07 Feb 2024 13:09:47 GMT\n[log] ###日志：  v   vary: Accept-Encoding\n[log] ###日志：  v   content-encoding: gzip\n[log] ###日志：  v   age: 2404\n[log] ###日志：  v   content-type: application/json;charset=UTF-8\n[log] ###日志：  v   x-source: C/200\n[log] ###日志：  v   server: marco/2.20\n[log] ###日志：  v   x-request-id: c58182a21ddcaed97d76dbb49f4771d8; 32238019a67857706c0e40b6dd0e1238\n[log] ###日志：  v   via: S.mix-hz-fdi1-213, T.213.H, V.mix-hz-fdi1-217, T.194.H, M.cun-he-sjw8-194\n[log] ###日志：  v   expires: Wed, 07 Feb 2024 13:19:43 GMT\n[log] ###日志：  v  Response Text:\n[log] ###日志：  v  {\"message\":\"success感谢又拍云(upyun.com)提供CDN赞助\",\"status\":200,\"date\":\"20241230\",\"time\":\"2024-12-30 16:40:54\",\"cityInfo\":{\"city\":\"天津市\",\"citykey\":\"101030100\",\"parent\":\"天津\",\"updateTime\":\"15:13\"},\"data\":{\"shidu\":\"16%\",\"pm25\":11.0,\"pm10\":61.0,\"quality\":\"良\",\"wendu\":\"1.7\",\"ganmao\":\"极少数敏感人群应减少户外活动\",\"forecast\":[{\"date\":\"30\",\"high\":\"高温 8℃\",\"low\":\"低温 -6℃\",\"ymd\":\"2024-12-30\",\"week\":\"星期一\",\"sunrise\":\"07:29\",\"sunset\":\"16:57\",\"aqi\":46,\"fx\":\"西北风\",\"fl\":\"3级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"31\",\"high\":\"高温 5℃\",\"low\":\"低温 -3℃\",\"ymd\":\"2024-12-31\",\"week\":\"星期二\",\"sunrise\":\"07:30\",\"sunset\":\"16:58\",\"aqi\":54,\"fx\":\"西风\",\"fl\":\"2级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"01\",\"high\":\"高温 5℃\",\"low\":\"低温 -4℃\",\"ymd\":\"2025-01-01\",\"week\":\"星期三\",\"sunrise\":\"07:30\",\"sunset\":\"16:59\",\"aqi\":59,\"fx\":\"东北风\",\"fl\":\"2级\",\"type\":\"多云\",\"notice\":\"阴晴之间，谨防紫外线侵扰\"},{\"date\":\"02\",\"high\":\"高温 2℃\",\"low\":\"低温 -2℃\",\"ymd\":\"2025-01-02\",\"week\":\"星期四\",\"sunrise\":\"07:30\",\"sunset\":\"17:00\",\"aqi\":50,\"fx\":\"东北风\",\"fl\":\"2级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"03\",\"high\":\"高温 4℃\",\"low\":\"低温 -5℃\",\"ymd\":\"2025-01-03\",\"week\":\"星期五\",\"sunrise\":\"07:30\",\"sunset\":\"17:00\",\"aqi\":65,\"fx\":\"西风\",\"fl\":\"2级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"04\",\"high\":\"高温 5℃\",\"low\":\"低温 -5℃\",\"ymd\":\"2025-01-04\",\"week\":\"星期六\",\"sunrise\":\"07:30\",\"sunset\":\"17:01\",\"aqi\":86,\"fx\":\"西南风\",\"fl\":\"1级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"05\",\"high\":\"高温 7℃\",\"low\":\"低温 -2℃\",\"ymd\":\"2025-01-05\",\"week\":\"星期日\",\"sunrise\":\"07:30\",\"sunset\":\"17:02\",\"aqi\":75,\"fx\":\"东北风\",\"fl\":\"2级\",\"type\":\"小雪\",\"notice\":\"小雪虽美，赏雪别着凉\"},{\"date\":\"06\",\"high\":\"高温 7℃\",\"low\":\"低温 -2℃\",\"ymd\":\"2025-01-06\",\"week\":\"星期一\",\"sunrise\":\"07:30\",\"sunset\":\"17:03\",\"aqi\":31,\"fx\":\"西北风\",\"fl\":\"3级\",\"type\":\"多云\",\"notice\":\"阴晴之间，谨防紫外线侵扰\"},{\"date\":\"07\",\"high\":\"高温 6℃\",\"low\":\"低温 -2℃\",\"ymd\":\"2025-01-07\",\"week\":\"星期二\",\"sunrise\":\"07:30\",\"sunset\":\"17:04\",\"aqi\":32,\"fx\":\"西北风\",\"fl\":\"3级\",\"type\":\"多云\",\"notice\":\"阴晴之间，谨防紫外线侵扰\"},{\"date\":\"08\",\"high\":\"高温 3℃\",\"low\":\"低温 -4℃\",\"ymd\":\"2025-01-08\",\"week\":\"星期三\",\"sunrise\":\"07:30\",\"sunset\":\"17:05\",\"aqi\":52,\"fx\":\"西北风\",\"fl\":\"2级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"09\",\"high\":\"高温 3℃\",\"low\":\"低温 -4℃\",\"ymd\":\"2025-01-09\",\"week\":\"星期四\",\"sunrise\":\"07:30\",\"sunset\":\"17:06\",\"aqi\":87,\"fx\":\"西南风\",\"fl\":\"2级\",\"type\":\"阴\",\"notice\":\"不要被阴云遮挡住好心情\"},{\"date\":\"10\",\"high\":\"高温 3℃\",\"low\":\"低温 -4℃\",\"ymd\":\"2025-01-10\",\"week\":\"星期五\",\"sunrise\":\"07:29\",\"sunset\":\"17:07\",\"aqi\":49,\"fx\":\"西北风\",\"fl\":\"2级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"11\",\"high\":\"高温 4℃\",\"low\":\"低温 -2℃\",\"ymd\":\"2025-01-11\",\"week\":\"星期六\",\"sunrise\":\"07:29\",\"sunset\":\"17:08\",\"aqi\":46,\"fx\":\"西北风\",\"fl\":\"2级\",\"type\":\"多云\",\"notice\":\"阴晴之间，谨防紫外线侵扰\"},{\"date\":\"12\",\"high\":\"高温 3℃\",\"low\":\"低温 -3℃\",\"ymd\":\"2025-01-12\",\"week\":\"星期日\",\"sunrise\":\"07:29\",\"sunset\":\"17:09\",\"aqi\":40,\"fx\":\"西北风\",\"fl\":\"3级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"},{\"date\":\"13\",\"high\":\"高温 3℃\",\"low\":\"低温 -5℃\",\"ymd\":\"2025-01-13\",\"week\":\"星期一\",\"sunrise\":\"07:29\",\"sunset\":\"17:10\",\"aqi\":68,\"fx\":\"南风\",\"fl\":\"2级\",\"type\":\"晴\",\"notice\":\"愿你拥有比阳光明媚的心情\"}],\"yesterday\":{\"date\":\"29\",\"high\":\"高温 6℃\",\"low\":\"低温 -5℃\",\"ymd\":\"2024-12-29\",\"week\":\"星期日\",\"sunrise\":\"07:29\",\"sunset\":\"16:56\",\"aqi\":100,\"fx\":\"西南风\",\"fl\":\"2级\",\"type\":\"多云\",\"notice\":\"阴晴之间，谨防紫外线侵扰\"}}}\n[log] ###日志：  v  useTime:0分:0秒:215毫秒\n[log] ###日志：  v  Response url :http://t.weather.sojson.com/api/weather/city/101030100\n[log] ###日志：  v  ***************** Response End *****************\n[log] ###日志：  v  useJsonAdapter：true\n```\n\n ### 对于线上的APP接口信息，也可通过埋点的RxNet查看请求日志信息。\n\n```dart     \n打开调试日志窗口： RxNet.showDebugWindow(context);\n关闭调试日志窗口： RxNet.closeDebugWindow();\n```\n\n## 调试窗口：\n![调试窗口](https://github.com/zhengzaihong/rxnet/blob/master/images/app_logcat.jpg) \n\n## 对HarmonyOS也支持：\n![HarmonyOS-example.gif](https://github.com/zhengzaihong/rxnet/blob/master/images/HarmonyOS-example.gif)\n\n\n\n## 📝 总结\n\n### 核心要点\n\n1. **executeStream() 返回 Stream**\n    - 需要调用 `listen()` 才能开始监听\n    - 必须保存 `StreamSubscription` 以便后续取消\n    - 立即取消会导致回调无法执行\n    - 应该在 `dispose()` 或用户操作时取消\n\n\n2. **选择合适的请求方式**\n    - 单次请求：`request()` 或 `execute()`\n    - 轮询请求：`executeStream()`\n    - 需要取消：使用 `CancelToken`\n\n3. **记得清理资源**\n    - 在 `dispose()` 中取消订阅\n    - 避免内存泄漏\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhengzaihong%2Frxnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhengzaihong%2Frxnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhengzaihong%2Frxnet/lists"}