Is there any way to get round figure value in flutter [duplicate]
need to round with nearer value
5680 - should be rounded as 6000 (nearer value)
9450 - should be rounded as 9000
....
I have seen similar questions in stack flow questions but those are not solving my requirements
Try this
import 'dart:math';
int getRound(int num){
int power = num.toString().length - 1;
var p = num / pow(10, power);
num = int.parse(p.toStringAsFixed(0)) * pow(10, power).toInt();
return num;
}
print("NUM " + getRound(949750).toString());
results
NUM 900000