Khalil Khalil
Khalil Khalil

Reputation: 117

Flutter http get precent of completion?

Hy everybody,

I try now to get the precent of completion of a http get request, but this cann't work, every time I get this error:

flutter: Bad state: Can't finalize a finalized Request.

Code I writed:

http.Response response = await client.get(url, headers: {"email": email, "password": password});

      var __ = await client.send(response.request);

      var length = response.contentLength;
      var received = 0;


      __.stream.map((s) {
          received += s.length;
          print("${(received / length) * 100} %");
          return 1;
        });

finally I should get a json data.

Could have anyone a ideea, how can this fixed or other programmed?

Upvotes: 0

Views: 154

Answers (1)

Pompidou
Pompidou

Reputation: 607

use Dio package it includes up/download status counter

Upvotes: 2

Related Questions