cToCurrency method
String
cToCurrency({
- dynamic removePointValueIfEmpty = true,
- dynamic symbol = '₹ ',
- dynamic currencyFormat = 'HI',
- dynamic decimalDigits = 2,
Converts a number string to a custom currency format.
Implementation
String cToCurrency({
removePointValueIfEmpty = true,
symbol = '₹ ',
currencyFormat = 'HI',
decimalDigits = 2,
}) {
var emptyPoint = '.' +
cBuildString(
(sb) {
for (var i = 0; i < decimalDigits; i++) {
sb.write('0');
}
},
);
var value = NumberFormat.currency(
symbol: symbol,
locale: currencyFormat,
decimalDigits: decimalDigits,
).format(double.parse(this));
return (removePointValueIfEmpty) ? value.replaceAll(emptyPoint, '') : value;
}