flutter 更新app下载安装
刚开始用的OtaUpdate插件,插件内部使用downloadmanager实现的国内有很多机型不支持
思路:不想自己造轮子 使用网上现有插件
一、使用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();
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
