asTwoDecimals property

String get asTwoDecimals

Formats this number as a string with up to two decimal places.

Trailing zeros are removed automatically.

Example:

3.14159.asTwoDecimals; // returns: '3.14'
5.0.asTwoDecimals;     // returns: '5'
2.567.asTwoDecimals;   // returns: '2.57' (rounded)

Implementation

String get asTwoDecimals => doublePrettyFormat.format(this);