flutter 更新app下载安装

编程知识 更新时间:2023-05-02 19:46:42
刚开始用的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 == DownloadTaskStatusplete) {
        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();

更多推荐

flutter 更新app下载安装

本文发布于:2023-04-28 09:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/21de7450769c48764998370edbb5288b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:flutter   app

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 108258文章数
  • 27372阅读数
  • 0评论数