Skip to content

Commit 1621ef4

Browse files
committed
App版本更新下载文件重命名
1 parent 2729dae commit 1621ef4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/ui/widget/app_update.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class AppUpdateButton extends StatelessWidget {
3232
if (appUpdateInfo?.buildHaveNewVersion ?? false) {
3333
bool result =
3434
await showUpdateAlertDialog(context, appUpdateInfo);
35-
if (result == true)
36-
downloadApp(context, appUpdateInfo.downloadURL);
35+
if (result == true) downloadApp(context, appUpdateInfo);
3736
} else {
3837
showToast(S.of(context).appUpdateLeastVersion);
3938
}
@@ -48,7 +47,7 @@ Future checkAppUpdate(BuildContext context) async {
4847
AppUpdateInfo appUpdateInfo = await AppUpdateModel().checkUpdate();
4948
if (appUpdateInfo?.buildHaveNewVersion ?? false) {
5049
bool result = await showUpdateAlertDialog(context, appUpdateInfo);
51-
if (result == true) downloadApp(context, appUpdateInfo.downloadURL);
50+
if (result == true) downloadApp(context, appUpdateInfo);
5251
}
5352
}
5453

@@ -90,13 +89,14 @@ showUpdateAlertDialog(context, AppUpdateInfo appUpdateInfo) async {
9089
));
9190
}
9291

93-
Future downloadApp(BuildContext context, String url) async {
92+
Future downloadApp(BuildContext context, AppUpdateInfo appUpdateInfo) async {
93+
var url = appUpdateInfo.downloadURL;
9494
var extDir = await getExternalStorageDirectory();
9595
debugPrint('extDir path: ${extDir.path}');
96-
97-
String apkPath = extDir.path + '/' + url.split('/').last;
96+
String apkPath =
97+
'${extDir.path}/FunAndroid_${appUpdateInfo.buildVersion}_${appUpdateInfo.buildVersionNo}_${appUpdateInfo.buildBuildVersion}.apk';
9898
File file = File(apkPath);
99-
debugPrint('file path: ${file.path}');
99+
debugPrint('apkPath path: ${file.path}');
100100
if (!file.existsSync()) {
101101
// 没有下载过
102102
if (await showDownloadDialog(context, url, apkPath) ?? false) {

0 commit comments

Comments
 (0)