by @kodeazy
flutter How to dispaly double value upto desired number of decimal points?
- Here we use
toStringAsFixed()
function to get the desired number of decimal points after the number. - suppose
double number = 123.4567890
. here to get upto 3 number after decimal point we usenumber.toStringAsFixed(3)
. -
Below is an example program
void main() { double number = 123.4567890; print((number).toStringAsFixed(2)); }
-
Inside
toStringAsFixed(2)
method we have 2 as parameter so we get upto 2 decimal points.Output:
123.46