简体   繁体   中英

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.

You can set "completed" rate of a progress indicator like this:

CircularProgressIndicator(value: 0.5)

The above will result in a 50% indicator. 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.

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,
      ),
    );
  },
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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