Flutter: How to get upload / download progress for http requests

后端 未结 3 1185
误落风尘
误落风尘 2020-12-01 10:17

I am writing an app that uploads an image to a server, and instead of just showing a spinner, I\'d love to be able to get progress on the status of that upload.

Ad

3条回答
  •  伪装坚强ぢ
    2020-12-01 10:43

    Try dio library. The onSendProgress callback would be helpful.

    example:

    response = await dio.post(
      "http://www.example.com",
      data: data,
      onSendProgress: (int sent, int total) {
        print("$sent $total");
      },
    );
    

    Reference: https://github.com/flutterchina/dio/issues/103

提交回复
热议问题