toStringAsPrecisionOrInt method
Returns a string of the number rounded to precision number of decimals, or less if possible
Implementation
String toStringAsPrecisionOrInt(int precision) {
final remainder = (this * pow(10, precision)) % 1;
if (remainder != 0) {
return toStringAsFixed(precision);
} else if (this - truncate() != 0) {
return toString();
} else {
return truncate().toString();
}
}