app_version_update 包简化了检查已安装的应用版本是否与 Google Play 商店或 Apple App Store 上可用的最新版本匹配的过程。该包使开发者能够无需依赖第三方服务即可编程验证更新。该包支持 Android、iOS、macOS、Windows 和 Linux 等多个平台,非常适合跨平台应用。通过比较本地版本号与商店版本号,它可在必要时提示用户进行更新。
适合场景
启动时检查应用更新
通过应用内对话框提示用户更新
验证跨平台的版本一致性
在后台自动检查更新
支持多平台应用
主要特点
跨平台兼容性
版本比较的简单 API
与 Google Play 和 Apple App Store 的集成
轻量且无依赖
实时版本验证
适合对象
跨平台 Flutter 应用
需要自动更新提示的应用程序
寻求最小化设置的开发者
针对 Android 和 iOS 的项目
需要版本同步验证的应用
使用建议
需要互联网连接以进行商店查询
仅限应用商店和应用市场
不支持替代应用分发
版本代码格式必须符合商店预期
频繁检查时可能需要处理速率限制
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Retrieve version and url for local app update against store app
Android and iOS
final appleId = '284882215'; // If this value is null, its packagename will be consideredfinal playStoreId = 'com.facebook.katana'; // If this value is null, its packagename will be consideredawaitAppVersionUpdate.checkForUpdates(
appleId: appleId, playStoreId: playStoreId)
.then((data) async {
print(data.storeUrl);
print(data.storeVersion);
if(data.canUpdate!){
//showDialog(... your custom widgets view) //or use our widgets// AppVersionUpdate.showAlertUpdate// AppVersionUpdate.showBottomSheetUpdate// AppVersionUpdate.showPageUpdateAppVersionUpdate.showAlertUpdate(
appVersionResult: data, context: context);
}
});
Customize the Alert Dialog
// you also have some options to customize our Alert Dialog AppUpdateVersion.showAlertUpdate(
{BuildContext? context,
AppVersionResult? appVersionResult,
bool? mandatory = false,
String? title = 'New version available',
TextStyle titleTextStyle =
constTextStyle(fontSize: 24.0, fontWeight: FontWeight.w500),
String? content = 'Would you like to update your application?',
TextStyle contentTextStyle =
constTextStyle(fontSize: 16.0, fontWeight: FontWeight.w400),
ButtonStyle? cancelButtonStyle = constButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.redAccent)),
ButtonStyle? updateButtonStyle = constButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.green)),
String? cancelButtonText = 'UPDATE LATER',
String? updateButtonText = 'UPDATE',
TextStyle? cancelTextStyle = constTextStyle(color: Colors.white),
TextStyle? updateTextStyle = constTextStyle(color: Colors.white),
Color? backgroundColor = Colors.white})