toRepresentationString method
String
toRepresentationString({
- PaymentAmountStringOptions options = const PaymentAmountStringOptions(),
Returns the amount you would see displayed (e.g. EUR 0.25)
Implementation
String toRepresentationString(
{PaymentAmountStringOptions options =
const PaymentAmountStringOptions()}) {
String wholes, somes;
var negative = value < 0;
var integer = (negative ? -value : value).toString();
if (exponent <= 0) {
wholes = integer + ''.padRight(-exponent, '0');
somes = '';
} else if (integer.length <= exponent) {
wholes = '0';
somes = integer.padLeft(exponent, '0');
} else {
wholes = integer.substring(0, integer.length - exponent);
somes = integer.substring(integer.length - exponent);
}
var paddedWholes = wholes.padLeft(options.padIntegers, ' ');
var paddedSomes = somes.padRight(options.padFractions, '0');
var currencyString = options.currency ? currency + ' ' : '';
return (currencyString +
(negative ? '-' : '') +
paddedWholes +
(paddedSomes == '' ? '' : '.' + paddedSomes));
}