In C# I can do:
12341.4.ToString(\"##,#0.00\")
and the result is 12,345.40
What\'s the equivalent in dart?
I use it. it's working for me
class MoneyFormat {
String price;
String moneyFormat(String price) {
if (price.length > 2) {
var value = price;
value = value.replaceAll(RegExp(r'\D'), '');
value = value.replaceAll(RegExp(r'\B(?=(\d{3})+(?!\d))'), ',');
return value;
}
}
}
and in TextFormField
onChanged: (text) {
priceController.text = moneyFormat.moneyFormat(priceController.text);
}