Home > Blockchain >  Flutter - CircularProgressIndicator max value
Flutter - CircularProgressIndicator max value

Time:10-18

i'm trying to find a way to change max value of CircularProgressIndicator

child: CircularProgressIndicator(
                                strokeWidth: 10,
                                value: math().valuePercentage,
                                backgroundColor:
                                    Color.fromARGB(255, 255, 152, 152),
                                color: Color.fromARGB(255, 233, 54, 54),

i was trying to do it with some math, but i stuck on this:

class math {
  double valuePercentage = kcalData().Target / 10000;
}

for example, we have 3216 kcal and the maximum of CircularProgressIndicator is 1.0, so i decide to devide kcal value by 10000, but i want to make a maximum from my Target value. I'm bad at math, so maybe some of you can get it... Any ideas? Or maybe there is another way to do this?

edit: maximum of indicator equals 1.0, can't set no more

CodePudding user response:

value: currentValue / totalValue,

currentValue: value which you want to show on your indicator

totalValue: max value of your progressIndicator

CodePudding user response:

Let's say your target 10000. This is the maximum. If you want to find how much is the percentage of 3126 in relation with 10000, then you have to divide 3126 with 10000. If you want to have a different max every time, then divide your value with your max.

  • Related