formatAsString method
Formats the number as a string with specified decimal places.
Example:
3.14159.formatAsString(2); // '3.14'
Implementation
String formatAsString(int decimals) {
assert(decimals >= 0, 'decimals must be non-negative');
return roundTo(decimals).toStringAsFixed(decimals);
}