设置进度条,并聆听firebase_storage来快速下载文件

时间:2019-12-25 17:30:00

标签: firebase flutter firebase-storage

在Flutter中使用firebase_storage下载文件时,如何使用进度条设置侦听器

  void downloadLectures(int lecture) async {
    createDirectory(lecture.toString());
    print("[HandleFiles] downloadLectures($lecture)");
    int audiosCount = this.lessonsCount[lecture - 3][lecture];
    Directory appDocDirectory = await getApplicationDocumentsDirectory();

    for(int i = 1; i <= audiosCount; i++) {
      File file = File('${appDocDirectory.path}/downloads/$lecture/$i.wav');
      StorageReference ref = FirebaseStorage.instance.ref().child("audios/$lecture/$i.wav");
      print("Doenloading $i.wav");
      StorageFileDownloadTask downloadTask = ref.writeToFile(file);
      int byteNumber = (await downloadTask.future).totalByteCount;
      print("byteNumber: $byteNumber");
    }
  }

0 个答案:

没有答案