Home > Mobile >  how can I scale the the numbers in flutter
how can I scale the the numbers in flutter

Time:03-25

I have to scale the numbers to be between 0 and 9 how can I do that in flutter application?

my data is from 0.000001 to >500,

and I need it to be from 0 to 9

CodePudding user response:

For min-max normalization:

Min= 0.000001 Max= n ( you need to define the upperlimit to replace >500)

New value= (Value * 9) / (max-min)

CodePudding user response:

The simplest way to do this is to first normalize the data to the 0-1 range:

final normalized = (data - min) / (max - min);

And then multiply it by your new max:

final converted = normalized * 9;
  • Related