微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

flutter Dynamic updates 热更新 版本更新

Flutter  Dynamic updates

 

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

 

我们现在使用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();

  

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐