parsePriceCents static method

String parsePriceCents(
  1. dynamic p
)

Implementation

static String parsePriceCents(p) {
  if (p != null && double.tryParse(p) != null) {
    double price = double.parse(p) / 100;
    if (price % 1 == 0) {
      return NumberFormat.currency(locale: 'eu', symbol: '', decimalDigits: 0).format(price.round());
    }
    return NumberFormat.currency(locale: 'eu', symbol: '', decimalDigits: 2).format(price);
  }
  return "0";
}