比較新的解釋
https://juejin.im/entry/5c85c959f265da2d881b5eb8
https://my.oschina.net/u/1464083/blog/2978809
flutter Dynamic updates
flutter OtaUpdate CodePush
https://blog.csdn.net/weixin_30512027/article/details/85772097
https://msd.misuland.com/pd/3127746505234976194
https://my.oschina.net/wupeilin/blog/3035732
唯一找到的 APP熱更新資料
https://github.com/dengyin2000/dynamic_widget
Code Push/Hot update
我們現在使用flutter更新版本
下載apk:
引入
dependencies:
flutter_downloader: 1.1.3
taskId = await FlutterDownloader.enqueue(
url: url,//服務端提供apk文件下載路徑
savedDir: (await getExternalStorageDirectory()).path.toString(),//本地存放路徑
fileName: “xiangta_” + netCode + “.apk”,//存放文件名
showNotification: false,//是否顯示在通知欄
openFileFromNotification: false,//是否在通知欄可以點擊打開此文件
);
//taskId為任務id (與完成下載的文件成一一對應)open是執行打開 打開需要任務id 相信你已經找到方向了
FlutterDownloader.registerCallback((taskId, status, progress) {
if (status == DownloadTaskStatus.complete) {
//下載完成
FlutterDownloader.open(taskId:taskId));
} else if (status == DownloadTaskStatus.failed) {
//下載出錯
}
});
---------
一、使用FlutterDownloader下載
二、open_file打開文件自帶安裝(FlutterDownloader自帶打開文件,但不能打開app不知道為啥)
代碼:
1、下載監聽
FlutterDownloader.registerCallback((id, status, progress) {
print(
'Download task ($id) is in status ($status) and process ($progress)');
if (status == DownloadTaskStatus.complete) {
OpenFile.open(_localPath);
FlutterDownloader.open(taskId: id);
}
});
2、下載
final taskId = await FlutterDownloader.enqueue(
url: url,
savedDir: _localPath,
showNotification:
true, // show download progress in status bar (for Android)
openFileFromNotification:
true, // click on notification to open downloaded file (for Android)
);
final tasks = await FlutterDownloader.loadTasks();
