priceFormat static method

String priceFormat({
  1. required double? price,
  2. String? priceUnit,
  3. bool isContact = false,
})

Implementation

static String priceFormat(
    {required double? price, String? priceUnit, bool isContact = false}) {
  if (price != null && price != 0) {
    final currencyFormatter = NumberFormat('#,###', 'VI');
    if (priceUnit != null) {
      return currencyFormatter.format(price) + " " + priceUnit;
    } else {
      return currencyFormatter.format(price) + "đ";
    }
  } else {
    if (priceUnit != null) {
      return "0" + priceUnit;
    } else {
      if (isContact) {
        return "text_contact";
      } else {
        return "0đ";
      }
    }
  }
}