# flutter_upgrader **Repository Path**: TimeOfPassage/flutter_upgrader ## Basic Information - **Project Name**: flutter_upgrader - **Description**: 升级自定义,满足自定义需求 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2023-08-23 - **Last Updated**: 2023-11-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 一个 Flutter 应用升级插件, 支持 Android 和 IOS, 插件的构思和设计来均自于 [flutter_app_upgrade](https://github.com/LaoMengFlutter/flutter-do/tree/master/flutter_app_upgrade) # 安装 1. 在 `pubspec.yaml` 添加 ``` dependencies: flutter_upgrader: ^1.0.7 ``` 2. 在命令行运行如下 ``` flutter pub get ``` # 使用 ## Android 1. 在 `android/app/src/main/AndroidManifest.xml` 添加 provider ```xml ... ``` 2. 新增 `android/app/src/main/res/xml/file_paths.xml` 文件 ```xml ``` 3. 点击升级前往应用商店 ```dart // 一般通过远程接口调用获取 final Future appUpgradeInfo = Future.value( AppUpgradeInfo( title: '更新提示', contents: ['有新版本哟,请更新~', '修复了设备定位bug', '优化认证操作体验'], force: true, // 是否强制升级 ), ); // 获取已上架的应用市场, 根据应用包名,例: 'com.flutter.app' final appMarketInfos = AppMarketManager.getAppMarketList( await FlutterUpgradeChanneler.getInstallMarket(['com.flutter.app']), ); // 升级应用 Api AppUpgradeManager.upgrade( context, // BuildContext appUpgradeInfo, appMarketInfo: appMarketInfos[0], onCancel: () {}, onOk: () {}, ); ```

4. 从指定的 Url 下载 apk ```dart // 一般通过远程接口调用获取 final Future appUpgradeInfo = Future.value( AppUpgradeInfo( title: '更新提示', contents: ['有新版本哟,请更新~', '修复了设备定位bug', '优化认证操作体验'], force: true, // 是否强制升级 ), ); // 升级应用 Api AppUpgradeManager.upgrade( context, // BuildContext appUpgradeInfo, apkDownloadUrl: 'http://xxx.xxx.com/upgrade.apk', onCancel: () {}, onOk: () {}, ); ```

## IOS 1. 点击升级前往应用商店 ```dart // 一般通过远程接口调用获取 final Future appUpgradeInfo = Future.value( AppUpgradeInfo( title: '更新提示', contents: ['有新版本哟,请更新~', '修复了设备定位bug', '优化认证操作体验'], force: true, // 是否强制升级 ), ); // 升级应用 Api AppUpgradeManager.upgrade( context, // BuildContext appUpgradeInfo, iosAppId: 'xxxxxxxx', // ios appId onCancel: () {}, onOk: () {}, ); ```