priceCeil static method

String priceCeil(
  1. double? value, {
  2. int lengthFixed = 2,
  3. int? lengthMax,
})

number transform 5: from

Implementation

static String priceCeil(
  double? value, {
  int lengthFixed = 2,
  int? lengthMax,
}) {
  if (value == null) {
    return '~';
  }
  final int x = pow(10, lengthMax ?? lengthFixed) as int;
  final double price = (value * x).ceilToDouble() / x;
  final String tailDecimals =
      lengthMax == null ? '' : "#" * (lengthMax - lengthFixed);
  return NumberFormat(
          ",##0${lengthFixed > 0 ? '.' : ''}${"0" * lengthFixed}$tailDecimals",
          "en_US")
      .format(price);
}