mx_moneyFmt method
Implementation
String mx_moneyFmt({int digits = 2, bool hasPlus = false}) {
var splitText = (digits > 0 ? '.' : '');
if (this == null) return '0' + splitText + '0' * digits;
var result = "${this!.toDouble().toStringAsFixed(digits)}";
if (digits == 2) {
if (this.toString().isInteger || result.endsWith('00')) {
return this?.toInt().mxText ?? '0';
}
result = "${this!.toDouble().toStringAsFixed(digits + 1)}";
return result.substring(0, result.length - 1);
}
if (hasPlus) return "${this! > 0 ? '+' : '-'}${result.replaceAll('-', '')}";
return result;
}