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