带有flutter http post上传的进度指示器?

问题描述

我试图在 Flutter 上使用带有 dio 包的进度指示器来发布,但是在我发布上传文件时进度没有更新。尽管进度显示在控制台打印中,但 ui 不会使用 onsendprogress 回调进行更新。 ui只在上传完成后更新,图片比例等于100%。如何使 ui 更新更频繁并随着打印命令的更新而更新?我希望为发布请求创建某种进度条。

final response2 = await dio.post(
  "uploadurlsample",data: formData,options: Options(contentType: Headers.formUrlEncodedContentType),onSendProgress: (int sent,int total) {
    print("$sent $total"); //works perfectly fine
    double ratio = sent / total;

    setState(() {
      imageratio = ": " + (ratio * 100).toStringAsFixed(0) + " %";
    });
   //imageratio does not update in the UI
  },);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)