In Dart to show fixed fraction digits after point values we will use toStringAsFixed() function. The toStringAsFixed() function converts number into double number with fixed fraction digits. Here fractionDigits means how many digits we want to show after point.
Syntax:
String toStringAsFixed(int fractionDigits)
Flutter Dart Show Fixed Number After Point Value
1. We will converting normal double number into fixed fraction digit number with toStringAsFixed() function.
void main() {
double a = 3.123456789;
print(a);
var b = a.toStringAsFixed(3);
print(b);
double c = double.parse(a.toStringAsFixed(2));
print(c);
}
Output:
Comments
Post a Comment