price static method
- convert "12.3412" to "12.34"
- convert "12.0000" to "12"
Implementation
static String price( double? d ) {
//rounded xx.yy
d ??= 0.0;
double roundedTwoFraction = double.parse((d).toStringAsFixed(2));
//remove ".00" if found
String s = roundedTwoFraction.toString();
if( s.endsWith( ".00") ) {
s = s.replaceAll( ".00", "" );
}
//endfix
String rial = "\$";
return s + " " + rial ;
}