0

It's been 3 days that I try to fix an issue with the download of audio files with my Flutter application. When I try to download audio files, the request keep the "pending" status and finish with no error.

I have research a lot and find something about the contentLength of the client who is always at 0 but it doesn't help.

Now I have tried to make a get request to a website with sample audio files and it doesn't work too. I have tested via Postman and it always work.

My function:

Future<void> _download(String url, String filepath) async {
    final response = await this.get("https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3");// await this.get("$baseURL$url");

    log("Try to get audio files: ${response.isOk}");

    if (response.isOk) {
      File file = File(filepath);
      final raf = file.openSync(mode: FileMode.write);

      response.bodyBytes.listen((value) {
        raf.writeFromSync(value);
      }, onDone: () {
        log("closed $filepath");
        raf.closeSync();
      });
    }
  }

The response.isOk is always false.

I used GetConnect from GetX package who used httpClient.

Via Dart devtools I obtain this from the request:

https://prnt.sc/1q3w33z
https://prnt.sc/1q3x9ot

Tryliom
  • 895
  • 1
  • 12
  • 37

1 Answers1

0

So I used another package: Dio and now it works.

Tryliom
  • 895
  • 1
  • 12
  • 37