简体   繁体   English

如何在 flutter 中设置循环进度指示器的加载值,例如 60 天的进度百分比?

[英]How to Set the Loading Value for the Circular progresss Indicator like progress percentage for 60 days in flutter?

How to Set the loading value for the Circular progresss indicator like progress percentage in flutter for 60 days-Math formula?I need this stuff for my flutter project,Sorry if i am asking something silly:-) Note : I'm new to this amazing flutter development.如何设置循环进度指示器的加载值,例如 flutter 中 60 天的进度百分比 - 数学公式?我的 flutter 项目需要这些东西,对不起,如果我问的是愚蠢的事情:-)注意:我是新手惊人的 flutter 开发。

You can set "completed" rate of a progress indicator like this:您可以像这样设置进度指示器的“完成”率:

CircularProgressIndicator(value: 0.5)

The above will result in a 50% indicator.以上将产生一个 50% 的指标。 All you have to do is use a member as value in a StatefulWidget and use setState to update it according to the desired percentage.您所要做的就是在StatefulWidget中使用成员作为值,并使用setState根据所需的百分比对其进行更新。

Also you can use it to indicate the progress when loading an image:您还可以使用它来指示加载图像时的进度:

Image.network(
  '<url>',
  height: 50,
  loadingBuilder: (BuildContext context, Widget child,
      ImageChunkEvent? loadingProgress) {
    if (loadingProgress == null) {
      return child;
    }
    return Center(
      child: CircularProgressIndicator(
        value: loadingProgress.expectedTotalBytes != null
            ? loadingProgress.cumulativeBytesLoaded /
                loadingProgress.expectedTotalBytes!
            : null,
      ),
    );
  },
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM