formatDecimal method

String formatDecimal(
  1. dynamic value
)

Formats a dynamic value as a decimal string with two decimal places.

Uses the "0.00" pattern and "en" locale for formatting.

Implementation

String formatDecimal(dynamic value) {
  if (value is int) value = value.toDouble();

  double valor = value == 0 ? 0.0 : value;

  final formatter = NumberFormat("0.00", "en");
  String newText = formatter.format(valor);
  return newText;
}