formatCurrency method
Implementation
String formatCurrency() {
if (this >= 1e9) {
// Billion
return '${(this / 1e9).toStringAsFixed(1)}B';
} else if (this >= 1e6) {
// Million
return '${(this / 1e6).toStringAsFixed(1)}M';
} else {
var formatter = NumberFormat('###,###.000');
var formattedNum = this == 0 ? '0' : formatter.format(this);
if (formattedNum.endsWith('.000')) {
formattedNum = formattedNum.substring(0, formattedNum.length - 4);
}
return formattedNum;
}
}