{"id":19765678,"url":"https://github.com/xuexiangjys/flutter_xupdate","last_synced_at":"2025-04-05T08:07:40.630Z","repository":{"id":43882237,"uuid":"238181475","full_name":"xuexiangjys/flutter_xupdate","owner":"xuexiangjys","description":"A Flutter plugin for XUpdate(Android Version Update Library)","archived":false,"fork":false,"pushed_at":"2023-12-15T02:48:56.000Z","size":2469,"stargazers_count":291,"open_issues_count":11,"forks_count":114,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T07:07:04.161Z","etag":null,"topics":["flutter","flutter-plugin","xupdate"],"latest_commit_sha":null,"homepage":"https://github.com/xuexiangjys/flutter_xupdate/wiki","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xuexiangjys.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":"https://gitee.com/xuexiangjys/Resource/blob/master/doc/sponsor.md"}},"created_at":"2020-02-04T10:38:57.000Z","updated_at":"2025-03-25T13:07:44.000Z","dependencies_parsed_at":"2023-12-15T03:41:55.397Z","dependency_job_id":"53c99fc9-1455-446e-adf7-e0225dffebc5","html_url":"https://github.com/xuexiangjys/flutter_xupdate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2Fflutter_xupdate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2Fflutter_xupdate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2Fflutter_xupdate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2Fflutter_xupdate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuexiangjys","download_url":"https://codeload.github.com/xuexiangjys/flutter_xupdate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305934,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["flutter","flutter-plugin","xupdate"],"created_at":"2024-11-12T04:18:59.493Z","updated_at":"2025-04-05T08:07:40.604Z","avatar_url":"https://github.com/xuexiangjys.png","language":"Dart","funding_links":["https://gitee.com/xuexiangjys/Resource/blob/master/doc/sponsor.md"],"categories":[],"sub_categories":[],"readme":"# flutter_xupdate\n\n[![Version](https://img.shields.io/badge/version-3.0.0-blue.svg)](https://pub.dev/packages/flutter_xupdate)\n[![Build Status](https://travis-ci.org/xuexiangjys/flutter_xupdate.svg?branch=master)](https://travis-ci.org/xuexiangjys/flutter_xupdate)\n[![Issue](https://img.shields.io/github/issues/xuexiangjys/flutter_xupdate.svg)](https://github.com/xuexiangjys/flutter_xupdate/issues)\n[![Star](https://img.shields.io/github/stars/xuexiangjys/flutter_xupdate.svg)](https://github.com/xuexiangjys/flutter_xupdate)\n\nA Flutter plugin for [XUpdate](https://github.com/xuexiangjys/XUpdate) -- Android Update Library。See the use [Chinese Document](https://github.com/xuexiangjys/flutter_xupdate/wiki) for details。\n\n## About me\n\n| WeChat public number   | juejin     |  zhihu    |  CSDN   |   jianshu   |   segmentfault  |   bilibili  |   toutiao\n|---------|---------|--------- |---------|---------|---------|---------|---------|\n| [我的Android开源之旅](https://t.1yb.co/Irse)  |  [Click me](https://juejin.im/user/598feef55188257d592e56ed/posts)    |   [Click me](https://www.zhihu.com/people/xuexiangjys/posts)       |   [Click me](https://xuexiangjys.blog.csdn.net/)  |   [Click me](https://www.jianshu.com/u/6bf605575337)  |   [Click me](https://segmentfault.com/u/xuexiangjys)  |   [Click me](https://space.bilibili.com/483850585)  |   [Click me](https://img.rruu.net/image/5ff34ff7b02dd)\n\n## Video tutorial\n\n[How to use flutter_xupdate](https://www.bilibili.com/video/BV1YK4y1S73e)\n\n## Stargazers over time\n\n[![Stargazers over time](https://starchart.cc/xuexiangjys/flutter_xupdate.svg)](https://starchart.cc/xuexiangjys/flutter_xupdate)\n\n## Getting Started\n\nYou should ensure that you add the `flutter_xupdate` as a dependency in your flutter project.\n\n```\n// pub 集成\ndependencies:\n  flutter_xupdate: ^3.0.0\n\n//github  集成\ndependencies:\n  flutter_xupdate:\n    git:\n      url: git://github.com/xuexiangjys/flutter_xupdate.git\n      ref: master\n```\n\n## UseCase\n\n### Initialization\n\n```\n  ///初始化\n   void initXUpdate() {\n     if (Platform.isAndroid) {\n       FlutterXUpdate.init(\n         ///是否输出日志\n         debug: true,\n         ///是否使用post请求\n         isPost: false,\n         ///post请求是否是上传json\n         isPostJson: false,\n         ///请求响应超时时间\n         timeout: 25000,\n         ///是否开启自动模式\n         isWifiOnly: false,\n         ///是否开启自动模式\n         isAutoMode: false,\n         ///需要设置的公共参数\n         supportSilentInstall: false,\n         ///在下载过程中，如果点击了取消的话，是否弹出切换下载方式的重试提示弹窗\n         enableRetry: false\n       ).then((value) {\n         updateMessage(\"初始化成功: $value\");\n       }).catchError((error) {\n         print(error);\n       });\n\n       FlutterXUpdate.setErrorHandler(\n           onUpdateError: (Map\u003cString, dynamic\u003e message) async {\n         print(message);\n         setState(() {\n           _message = \"$message\";\n         });\n       });\n     } else {\n       updateMessage(\"ios暂不支持XUpdate更新\");\n     }\n   }\n\n```\n\n### JSON Format\n\n```\n{\n  \"Code\": 0, //0代表请求成功，非0代表失败\n  \"Msg\": \"\", //请求出错的信息\n  \"UpdateStatus\": 1, //0代表不更新，1代表有版本更新，不需要强制升级，2代表有版本更新，需要强制升级\n  \"VersionCode\": 3,\n  \"VersionName\": \"1.0.2\",\n  \"ModifyContent\": \"1、优化api接口。\\r\\n2、添加使用demo演示。\\r\\n3、新增自定义更新服务API接口。\\r\\n4、优化更新提示界面。\",\n  \"DownloadUrl\": \"https://raw.githubusercontent.com/xuexiangjys/XUpdate/master/apk/xupdate_demo_1.0.2.apk\",\n  \"ApkSize\": 2048\n  \"ApkMd5\": \"...\"  //md5值没有的话，就无法保证apk是否完整，每次都会重新下载。框架默认使用的是md5加密。\n}\n```\n\n### CheckUpdate\n\n```\n  ///默认App更新\n  void checkUpdateDefault() {\n    FlutterXUpdate.checkUpdate(url: _updateUrl);\n  }\n\n  ///默认App更新 + 支持后台更新\n  void checkUpdateSupportBackground() {\n    FlutterXUpdate.checkUpdate(url: _updateUrl, supportBackgroundUpdate: true);\n  }\n\n  ///调整宽高比\n  void checkUpdateRatio() {\n    FlutterXUpdate.checkUpdate(url: _updateUrl, widthRatio: 0.6);\n  }\n\n  ///强制更新\n  void checkUpdateForce() {\n    FlutterXUpdate.checkUpdate(url: mUpdateUrl2);\n  }\n\n  ///自动模式, 如果需要完全无人干预，自动更新，需要root权限【静默安装需要】\n  void checkUpdateAutoMode() {\n    FlutterXUpdate.checkUpdate(url: _updateUrl, isAutoMode: true);\n  }\n\n  ///下载时点击取消允许切换下载方式\n  void enableChangeDownLoadType() {\n    FlutterXUpdate.checkUpdate(\n      url: _updateUrl,\n      overrideGlobalRetryStrategy: true,\n      enableRetry: true,\n      retryContent: \"Github下载速度太慢了，是否考虑切换蒲公英下载？\",\n      retryUrl: \"https://www.pgyer.com/flutter_learn\");\n  }\n```\n\n\n### Custom JSON Format\n\n1.Setting up a custom update parser\n\n```\nFlutterXUpdate.setCustomParseHandler(onUpdateParse: (String json) async {\n//Here is the custom JSON parsing\nreturn customParseJson(json);\n});\n\n///Resolve the custom JSON content to the UpdateEntity entity class\nUpdateEntity customParseJson(String json) {\n  AppInfo appInfo = AppInfo.fromJson(json);\n  return UpdateEntity(\n      hasUpdate: appInfo.hasUpdate,\n      isIgnorable: appInfo.isIgnorable,\n      versionCode: appInfo.versionCode,\n      versionName: appInfo.versionName,\n      updateContent: appInfo.updateLog,\n      downloadUrl: appInfo.apkUrl,\n      apkSize: appInfo.apkSize);\n}\n```\n\n2.Set the parameter `isCustomParse` to true\n\n```\nFlutterXUpdate.checkUpdate(url: _updateUrl3, isCustomParse: true);\n```\n\n### Update By UpdateEntity Directly\n\n```\n///直接传入UpdateEntity进行更新提示\nvoid checkUpdate8() {\n    FlutterXUpdate.updateByInfo(updateEntity: customParseJson(_customJson));\n}\n```\n\n### Custom Update Prompt Style\n\n\u003e Currently, only theme color and top picture customization are supported!\n\n1.Configure top picture, Path: `android/app/src/main/res/values/drawable`, For example:\n\n![](./example/art/6.png)\n\n2.Set the parameter `themeColor` 、 `topImageRes` and `buttonTextColor`\n\n```\n///自定义更新弹窗样式\nvoid customPromptDialog() {\n    FlutterXUpdate.checkUpdate(url: _updateUrl, themeColor: '#FFFFAC5D', topImageRes: 'bg_update_top', buttonTextColor: '#FFFFFFFF');\n}\n```\n\n【Note】: When you use the command `flutter build apk` to make a release package, If you use the `topImageRes` property, you must configure `shrinkResources` to false, otherwise the pop-up window will display an exception!\n\n![](./example/art/7.png)\n\n## Property value\n\n### Initialization\n\nName | Type | Default | Description\n:-|:-:|:-:|:-\ndebug | bool | false | Whether Output log\nisPost | bool | false | Whether use post request\nisPostJson | bool | false | Whether post request upload json format\ntimeout | int | 20000(ms) | Request response timeout\nisWifiOnly | bool | true | Whether update only under WiFi\nisAutoMode | bool | false | Whether to turn on automatic mode\nsupportSilentInstall | bool | false | Whether to support silent installation requires that the device has root permission\nenableRetry | bool | false | In the process of downloading, if you click Cancel, whether the pop-up window for retrying to switch the download mode will pop up\nretryContent | String | '' | Try the prompt content of the prompt pop-up window again\nretryUrl | String | '' | Retrying prompt pop-up URL to jump after clicking\nparams | Map | / | Public parameters to be set\n\n### CheckUpdate\n\nName | Type | Default | Description\n:-|:-:|:-:|:-\nurl | String | / | URL of version check\nparams | Map | / | Parameters\nsupportBackgroundUpdate | bool | false | Whether to support background updates\nisAutoMode | bool | false | Whether to turn on automatic mode\nisCustomParse | bool | false | Is it a custom resolution protocol\nthemeColor | String | '' | Apply pop-up theme color\ntopImageRes | String | '' | The name of the top picture resource in the pop-up window\nbuttonTextColor | String | '' | The color of the button text\nwidthRatio | double | / | Proportion of version update Prompter width to screen\nheightRatio | double | / | Proportion of version update Prompter height to screen\noverrideGlobalRetryStrategy | bool | false | Whether to override the global retry policy\nenableRetry | bool | false | In the process of downloading, if you click Cancel, whether the pop-up window for retrying to switch the download mode will pop up\nretryContent | String | '' | Try the prompt content of the prompt pop-up window again\nretryUrl | String | '' | Retrying prompt pop-up URL to jump after clicking\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuexiangjys%2Fflutter_xupdate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuexiangjys%2Fflutter_xupdate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuexiangjys%2Fflutter_xupdate/lists"}